Floating point roundoff error

A

Arne Vajhøj

Andrew said:
I have heard that if dealing with $, one should use 'cents'.
Or rather, use in int representation of cents, and only format
to dollars on output. Thoughts?

int is also used, but more work to do yourself. And rounding
can be tricky.

Oh - and always long - never int - 2 billion cents is just
20 million dollars.

Arne
 
A

Arne Vajhøj

Lew said:
Others say to keep a long of mils (if we're talking U.S. currency
units), giving one extra decimal digit of accuracy at the expense of one
in range.

But within the area more precision is not necessarily better.

Rounding rules is determined by business rules.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top