Code example for BigDecimal

Methods: doubleValue, subtract

0
		sub1 = new BigDecimal(1.234E-03);
		sub2 = new BigDecimal(3.423E-10);
		result = sub1.subtract(sub2);
		assertTrue("1.234E-03 - 3.423E-10 is wrong, " + result.doubleValue(),
				result.doubleValue() == 0.0012339996577);
		sub1 = new BigDecimal(1234.0123);
		sub2 = new BigDecimal(1234.0123000);
		result = sub1.subtract(sub2);
		assertTrue("1234.0123 - 1234.0123000 is wrong, " + result.doubleValue(),
				result.doubleValue() == 0.0);
	} 
 
	/** 
	 * @tests java.math.BigDecimal#toBigInteger() 
	 */ 
	public void test_toBigInteger() { 
		BigDecimal sub1 = new BigDecimal("-29830.989");
		BigInteger result = sub1.toBigInteger();
 
		assertTrue("the bigInteger equivalent of -29830.989 is wrong", result
				.toString().equals("-29830"));