To convert a long to a BigDecimal use:
// convert a long to BigDecimal, with some implied decimal places. BigDecimal d = BigDecimal.valueOf( theLong, decimalPlaces );
You can’t use ordinary arithmetic or comparison operators on BigDecimal. You must use methods like BigDecimal.add, .subtract, .multiply,. divide, .pow, .abs, .compareTo …
To convert your BigDecimal to a String for display you can use BigDecimal. toString or BigDecimal. toEngineeringString. It is also possible using Formatter and printf.
| You can get the freshest copy of this page from: | or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror) | |
| http://mindprod.com/jgloss/bigdecimal.html | J:\mindprod\jgloss\bigdecimal.html | |
![]() | ||
| Canadian Mind Products | ||
| mindprod.com IP:[65.110.21.43] | ||
| view Blog | Your face IP:[38.107.191.107] | |
| Feedback | You are visitor number 17,760. | |