BAEL-3130 overflow and underflow in java (#8381)
* BAEL-3131 Guide to Java HashMap http://jira.baeldung.com/browse/BAEL-3130 * Move test class to correct package http://jira.baeldung.com/browse/BAEL-3130
This commit is contained in:
parent
c5072b83f8
commit
0c3f780c4f
|
@ -0,0 +1,22 @@
|
||||||
|
package com.baeldung.overflow;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class OverflowUnitTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void positive_and_negative_zero_are_not_always_equal() {
|
||||||
|
|
||||||
|
double a = +0f;
|
||||||
|
double b = -0f;
|
||||||
|
|
||||||
|
assertTrue(a == b);
|
||||||
|
|
||||||
|
assertTrue(1/a == Double.POSITIVE_INFINITY);
|
||||||
|
assertTrue(1/b == Double.NEGATIVE_INFINITY);
|
||||||
|
|
||||||
|
assertTrue(1/a != 1/b);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue