So I thought my program was perfect until I tried to input "1.15" through this: Math.rint(amount*100)/100;
It outputs as 1.14
I don't get it. Other numbers work Please help, I don't know why is that.
Thank you!
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
So I thought my program was perfect until I tried to input "1.15" through this: Math.rint(amount*100)/100;
It outputs as 1.14
I don't get it. Other numbers work Please help, I don't know why is that.
Thank you!
Might be rounding.
URGENT! Due in one hour. Please help!
Still not urgent.
Improving the world one idiot at a time!
I would have been inclined to help you if you weren't rude by:
Marking your post as urgent.
Imposing a deadline upon us.
Crossposting.
Improving the world one idiot at a time!
I had a problem similar to this not long ago and I had to implement my numbers with the BigDecimal class... Basically it was a thing calculating money and it would give out very weird values when doing very simple math ( I recall 0.07 * 3 = 0.2100000000002 or something like that).