Batch Problem ($$$)

Status
Not open for further replies.

xdivenx

[H]ard|Gawd
Joined
Mar 4, 2008
Messages
1,941
I seem to be having a problem with this bit of code. It is just a smaller portion of the whole image.

set /p amnt=Initial Amount($):
set /p dwn=Down Payment ($):
set /p rte=Interest Rate (%%):


set /a loan=amnt-dwn
set /a interest=loan*(rte/100)
echo %interest%
pause

I don't understand why interest is not displaying the way I want it to. When I input 100 for the initial amount, 90 for the down payment, and a 50 percent interest rate, that leaves 10 dollars to be multiplied by .5, which should result in $5. Or atleast thats what I want it to do. What am I doing wrong, and how can I fix it?


(Note: This code is part of a really poorly written program. Please don't tell me I should be using a different method or condense my calculations. I just want to understand what is wrong in my division/math.

Edit: I just found
"In principle, it is also possible to do multiplication and division.but only whole numbers can be handled so the practical use is limited." So what is a workaround for this?



Winning answer gets $5.
 
You can multiply everything by 100 (or 10,000) to count cents instead of dollars. Then, use division and modulo to print your result.
 
You can multiply everything by 100 (or 10,000) to count cents instead of dollars. Then, use division and modulo to print your result.

Thats what I ended up doing, but there isn't a better work around?
 
It depends on what you mean by "better", and it depends more on why you're constrained to using the wrong tool.
 
the work around is not using the crappy windows command prompt to do financial calculations. Jesus christ.
 
58767470177416


Ive asked you twice.
 
What does "paypal?" mean? Are you asking me if that's an acceptable method of payment? If so, then, yes. If not, then you'll need to be clearer, as I can't guess what it is you want.
 
I'm glad you responded to my post instead of ignoring it all together. Let me be clearer.

Do you have paypal? Do you find paypal an acceptable method of payment for your services? Would you mind typing your paypal address so that I may send you $5?

Is that better? I apologize for my ridiculous assumption that one would be able to infer that I was asking your paypal address by typing "paypal?".
 
It's okay. It seems like you have a real chip on your shoulder, though. So why don't you just keep the money? Maybe it'll help you feel better.

Good luck with your project!
 
It's okay. It seems like you have a real chip on your shoulder, though. So why don't you just keep the money? Maybe it'll help you feel better.

Good luck with your project!

Dude, take the $5 bucks and go to taphouse after 10pm. $4 beer and a $1 tip, plus a chance of running into me.

On second thought, perhaps you'd rather avoid all that, and he really should keep his $5 ;).
 
It looks like it's treating all operations as 32-bit signed integer operations so when you perform (rte/100) it is treating the result as an integer, not a decimal, and truncating it to 0.
 
Status
Not open for further replies.
Back
Top