Skip to content

Commit ddd2cf9

Browse files
committed
Use doubleToRawLongBits for isNegativeZero
1 parent 57820f3 commit ddd2cf9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/main/java/org/truffleruby/language/RubyGuards.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
public abstract class RubyGuards {
1818

19+
private static final long NEGATIVE_ZERO_DOUBLE_BITS = Double.doubleToRawLongBits(-0.0);
20+
1921
// Basic Java types
2022

2123
public static boolean isBoolean(Object value) {
@@ -323,7 +325,7 @@ public static boolean isPositive(double value) {
323325
}
324326

325327
public static boolean isNegativeZero(double value) {
326-
return Double.valueOf(value).equals(-0.0);
328+
return Double.doubleToRawLongBits(value) == NEGATIVE_ZERO_DOUBLE_BITS;
327329
}
328330

329331
// Composite

0 commit comments

Comments
 (0)