Skip to content

Commit 49774bd

Browse files
Maiklinspivovarit
authored andcommitted
BAEL-3130 overflow and underflow in java (eugenp#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
1 parent 9d7960b commit 49774bd

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.baeldung.overflow;
2+
3+
import static org.junit.Assert.assertTrue;
4+
5+
import org.junit.Test;
6+
7+
public class OverflowUnitTest {
8+
9+
@Test
10+
public void positive_and_negative_zero_are_not_always_equal() {
11+
12+
double a = +0f;
13+
double b = -0f;
14+
15+
assertTrue(a == b);
16+
17+
assertTrue(1/a == Double.POSITIVE_INFINITY);
18+
assertTrue(1/b == Double.NEGATIVE_INFINITY);
19+
20+
assertTrue(1/a != 1/b);
21+
}
22+
}

0 commit comments

Comments
 (0)