Code example for BigDecimal

Methods: intValue

0
 
	/** 
	 * @tests java.math.BigDecimal#intValue() 
	 */ 
	public void test_intValue() { 
		BigDecimal int1 = new BigDecimal(value, 3);
		assertTrue("the int value of 12345.908 is not 12345",
				int1.intValue() == 12345);
		int1 = new BigDecimal("1.99");
		assertTrue("the int value of 1.99 is not 1", int1.intValue() == 1);
		int1 = new BigDecimal("23423419083091823091283933");
		// ran JDK and found representation for the above was -249268259 
		assertTrue("the int value of 23423419083091823091283933 is wrong", int1
				.intValue() == -249268259);
		int1 = new BigDecimal(-1235D);
		assertTrue("the int value of -1235 is not -1235",
				int1.intValue() == -1235);
	} 
 
	/** 
	 * @tests java.math.BigDecimal#longValue()