The Java Developers Almanac 1.4


Order this book from Amazon.

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

e126. Operating with Big Integer Values

    // Create via a string
    BigInteger bi1 = new BigInteger("1234567890123456890");
    
    // Create via a long
    BigInteger bi2 = BigInteger.valueOf(123L);
    
    bi1 = bi1.add(bi2);
    bi1 = bi1.multiply(bi2);
    bi1 = bi1.subtract(bi2);
    bi1 = bi1.divide(bi2);
    bi1 = bi1.negate();
    int exponent = 2;
    bi1 = bi1.pow(exponent);

 Related Examples
e127. Operating with Big Decimal 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.