There ought to be severe penalties for idiots that use
floating point dollars for financial applications.
If forced to use floating point (e.g. because customer
demands BASIC), then keep money amounts in whole pennies
(or whatever the smallest currency unit for the country
is), and divide by 100 (or whatever) for printing only (or
just add the decimal point yourself).
In many circumstances this is exactly what you can't do.floating point dollars for financial applications.
If forced to use floating point (e.g. because customer
demands BASIC), then keep money amounts in whole pennies
(or whatever the smallest currency unit for the country
is), and divide by 100 (or whatever) for printing only (or
just add the decimal point yourself).
The minute you need to calculate percentages you will get in to
the things like .0001254 of a cent, no matter what is you
smallest unit of currency.
I worked for a insurance company (using Business Basic) many
years ago on MAI and Prime gear, and we did everything as floats
with 14 places after the decimal point,and only rounded when
a human needed to see a number, and then used standard accounting
practices for rounding,
Rgds
Tim
base, use 10,000ths of a penny, but still use integer arithmetic
for your calculations.
Floating point has too many rounding errors to be trustworthy;
or, looking at it from another angle, floating-point calculations
cannot be 100% accurate because of the way it's implemented.
-gustavo
Advertencia:
La informacion contenida en este mensaje es confidencial y restringida y
esta destinada unicamente para el uso de la persona arriba indicada, Esta
comunicacion representa la opinion personal del remitente y no refleja
necesariamente la opinion de la Compa?ia. Se le notifica que esta
estrictamente prohibida cualquier difusion, distribucion o copia de este
mensaje. Si ha recibido esta comunicacion o copia de este mensaje por error,
o si hay problemas en la transmision, favor de comunicarse con el remitente.
Todo el correo electr?nico enviado para o desde esta direcci?n ser?
procesado por el sistema de correo corporativo de HEB. Tal correo
electr?nico esta sujeto a ser almacenado y puede ser revisado por alguien
ajeno al recipiente autorizado con el prop?sito de monitorear que se cumplan
las normas de seguridad de la empresa.