The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.math  [6 examples]

e127. Operating with Big Decimal Values

    // Create via a string
    BigDecimal bd1 = new BigDecimal("123456789.0123456890");
    
    // Create via a long
    BigDecimal bd2 = BigDecimal.valueOf(123L);
    
    bd1 = bd1.add(bd2);
    bd1 = bd1.multiply(bd2);
    bd1 = bd1.subtract(bd2);
    bd1 = bd1.divide(bd2, BigDecimal.ROUND_UP);
    bd1 = bd1.negate();

 Related Examples
e126. Operating with Big Integer Values
e128. Setting the Decimal Place of a Big Decimal Value
e129. Performing Bitwise Operations with BigInteger
e130. Parsing and Formatting a Big Integer into Binary, Octal, and Hexadecimal
e131. Parsing and Formatting a Byte Array into Binary, Octal, and Hexadecimal


© 2002 Addison-Wesley.