BAEL-3404 Review comments (#8181)
This commit is contained in:
parent
b68aca1d9d
commit
cc32b9f93d
|
@ -0,0 +1,5 @@
|
|||
package com.baeldung.strictfpUsage;
|
||||
|
||||
public strictfp interface Circle {
|
||||
double computeArea(double radius);
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue