BAEL-9683 Fix tutorials default-first build - ref# 156 (#5491)

* BAEL-9683 Fix tutorials default-first build - ref# 156

- Fix assertion error - loss of precision was happening because double was being divided by an integer

* BAEL-9683 Fix tutorials default-first build - ref# 156

- Fixed formatting
This commit is contained in:
Dhawal Kapil 2018-10-19 21:28:47 +05:30 committed by Eugen
parent 070bc10214
commit 10b4252646

View File

@ -1,6 +1,7 @@
package com.baeldung.maths; package com.baeldung.maths;
import static org.junit.Assert.assertTrue; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -11,10 +12,10 @@ public class MathSinUnitTest {
double angleInDegrees = 30; double angleInDegrees = 30;
double sinForDegrees = Math.sin(Math.toRadians(angleInDegrees)); // 0.5 double sinForDegrees = Math.sin(Math.toRadians(angleInDegrees)); // 0.5
double thirtyDegreesInRadians = 1/6 * Math.PI; double thirtyDegreesInRadians = (double) 1 / 6 * Math.PI;
double sinForRadians = Math.sin(thirtyDegreesInRadians); // 0.5 double sinForRadians = Math.sin(thirtyDegreesInRadians); // 0.5
assertTrue(sinForDegrees == sinForRadians); assertThat(sinForDegrees, is(sinForRadians));
} }
} }