Originally posted by meera rao:
I am storing all the currency values as double. When i calculate 2 double numbers, I don't get an output with 2 decimal places.
Can somebody help me convert it into 2 decimal places.
I know one option using NumberFormat. Are they any other ways of doing this
If you are doing any arithmetic operations with these currency values
you should consider using int or long instead of double. Assuming you are using U.S. currency, the int (or long) will store the number of pennies (instead of the number of dollars as you do in a double). You will then format the value as necessary for output. This approach avoids common rounding errors and lack of precision that is introduced by storing numbers as a floating-point value.
Keep Coding!
Layne