File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Cattle Drive and the fly likes float arithmetic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Cattle Drive
Bookmark "float arithmetic" Watch "float arithmetic" New topic

float arithmetic

Manisha Abhyankar

Joined: Jan 13, 2001
Posts: 1
I am trying to do float arithmetic for dollar amounts. The sum is not precise to the two decimal places of cents. It gets rounded up and the final total is different from the actual total by a few cents or a couple of dollars! Has anyone used float for accumulating totals precise to the two decimal places?
paul wheaton

Joined: Dec 14, 1998
Posts: 20271

Which assignment is this for?

permaculture Wood Burning Stoves 2.0 - 4-DVD set
I agree. Here's the link:
subject: float arithmetic
Similar Threads
Float decimal points..
Rounding off $$ amounts
trying to restrict decimal places in double
Float.valueOf is rounding 999999.99 to 1000000.00