Decimals and Floating Point Numbers
Keywords: Decimals Floating Point Numbers
Question:
I would want to know why the decimal part is not recognized in this script:decimals(2) amount=11222333.05 message("",ammount) ; =====> 11222333.00Answer:
11222333.05is considered a floating point number. Only (roughly) nine digits of precision are available for the display of floating point numbers. So you get 11222333.0 and that uses up your nine digits.
I like to do currency computations (in US$ anyway) in pennies ($0.01) instead of dollars with a fractional dollar to avoid these kinds of problems.
For integer numbers - the kind without the .xx -- the maximum size is about two billion ( 2,000,000,000 ) which, counting in pennies, can represent about 20 million dollars. I figure when I have to deal with more than twenty million dollars, I'll get a different program.
Article ID: W14142Filename: Decimals and Floating Point Numbers.txt