From 0c3f780c4f22b71548dfe926fc4cc49cda8f370e Mon Sep 17 00:00:00 2001 From: Maiklins Date: Sun, 15 Dec 2019 21:07:08 +0100 Subject: [PATCH] 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 --- .../baeldung/overflow/OverflowUnitTest.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 core-java-modules/core-java-lang-math/src/test/java/com/baeldung/overflow/OverflowUnitTest.java diff --git a/core-java-modules/core-java-lang-math/src/test/java/com/baeldung/overflow/OverflowUnitTest.java b/core-java-modules/core-java-lang-math/src/test/java/com/baeldung/overflow/OverflowUnitTest.java new file mode 100644 index 0000000000..b570592c7e --- /dev/null +++ b/core-java-modules/core-java-lang-math/src/test/java/com/baeldung/overflow/OverflowUnitTest.java @@ -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); + } +}