diff --git a/core-java-modules/core-java-numbers-conversions/src/test/java/com/baeldung/floatdoubleconversions/FloatDoubleConversionsTest.java b/core-java-modules/core-java-numbers-conversions/src/test/java/com/baeldung/floatdoubleconversions/FloatDoubleConversionsTest.java index 9c6b01e9de..9da50276a9 100644 --- a/core-java-modules/core-java-numbers-conversions/src/test/java/com/baeldung/floatdoubleconversions/FloatDoubleConversionsTest.java +++ b/core-java-modules/core-java-numbers-conversions/src/test/java/com/baeldung/floatdoubleconversions/FloatDoubleConversionsTest.java @@ -7,23 +7,27 @@ public class FloatDoubleConversionsTest { @Test public void whenDoubleType_thenFloatTypeSuccess(){ - double interestRatesYearly = 13.333333333333334; + double interestRatesYearly = 13.333333333333333; float interest = (float) interestRatesYearly; - Assert.assertEquals(13.333333f, interest, 0.000004f); + System.out.println(interest); //13.333333 + Assert.assertEquals(13.333333f, interest, 0.000001f); - Double monthlyRates = 2.111111111111112; + Double monthlyRates = 2.111111111111111; float rates = monthlyRates.floatValue(); - Assert.assertEquals(2.1111112f, rates, 0.00000013); + System.out.println(rates); //2.1111112 + Assert.assertEquals(2.1111111f, rates, 0.0000001f); } @Test public void whenFloatType_thenDoubleTypeSuccess(){ float gradeAverage =2.05f; double average = gradeAverage; - Assert.assertEquals(2.05, average, 0.06); + System.out.println(average); //2.049999952316284 + Assert.assertEquals(2.05, average, 0.01); - Float monthlyRates = 2.1111112f; + Float monthlyRates = 2.1111111f; Double rates = monthlyRates.doubleValue(); - Assert.assertEquals(2.11111112, rates, 0.0000002);//true + System.out.println(rates); //2.1111111640930176 + Assert.assertEquals(2.11111111, rates, 0.0000001);//true } }