Code example for BigDecimal

Methods: floatValue

0
 
	/** 
	 * @tests java.math.BigDecimal#floatValue() 
	 */ 
	public void test_floatValue() { 
		BigDecimal fl1 = new BigDecimal("234563782344567");
		assertTrue("the float representation of bigDecimal 234563782344567",
				fl1.floatValue() == 234563782344567f);
		BigDecimal fl2 = new BigDecimal(2.345E37);
		assertTrue("the float representation of bigDecimal 2.345E37", fl2
				.floatValue() == 2.345E37F);
		fl2 = new BigDecimal(-1.00E-44);
		assertTrue("the float representation of bigDecimal -1.00E-44", fl2
				.floatValue() == -1.00E-44F);
		fl2 = new BigDecimal(-3E12);
		assertTrue("the float representation of bigDecimal -3E12", fl2
				.floatValue() == -3E12F);
		fl2 = new BigDecimal(Double.MAX_VALUE);
		assertTrue(
				"A number can't be represented by float should return infinity",