BAEL-3404 Review comments (#8181)

This commit is contained in:
Shubhra Srivastava 2019-11-13 01:57:47 +05:30 committed by maibin
parent b68aca1d9d
commit cc32b9f93d
3 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,5 @@
package com.baeldung.strictfpUsage;
public strictfp interface Circle {
double computeArea(double radius);
}

View File

@ -0,0 +1,12 @@
package com.baeldung.strictfpUsage;
public strictfp class ScientificCalculator {
public double sum(double value1, double value2) {
return value1 + value2;
}
public double diff(double value1, double value2) {
return value1 - value2;
}
}

View File

@ -0,0 +1,18 @@
package com.baeldung.strictfpUsage;
import org.junit.Test;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
public class ScientificCalculatorUnitTest {
@Test
public void whenMethodOfstrictfpClassInvoked_thenIdenticalResultOnAllPlatforms() {
ScientificCalculator calculator = new ScientificCalculator();
double result = calculator.sum(23e10, 98e17);
assertThat(result, is(9.800000230000001E18));
result = calculator.diff(Double.MAX_VALUE, 1.56);
assertThat(result, is(1.7976931348623157E308));
}
}