Code example for BigInteger

Methods: multiply

0
 
    /** Convert an amount expressed in the way humans are used to into nanocoins. */ 
    public static BigInteger toNanoCoins(int coins, int cents) {
        assert cents < 100;
        BigInteger bi = BigInteger.valueOf(coins).multiply(COIN);
        bi = bi.add(BigInteger.valueOf(cents).multiply(CENT));
        return bi;
    } 
 
    /** 
     * Convert an amount expressed in the way humans are used to into nanocoins.<p> 
     * 
     * This takes string in a format understood by {@link BigDecimal#BigDecimal(String)}, 
     * for example "0", "1", "0.10", "1.23E3", "1234.5E-5". 
     *  
     * @throws ArithmeticException if you try to specify fractional nanocoins 
     **/ 
    public static BigInteger toNanoCoins(String coins){
        return new BigDecimal(coins).movePointRight(8).toBigIntegerExact();
    } 
Stop searching for code, let great code find you!  Add Codota to your java IDE