From 1d118931cf3b178fb7b16948b8612aef646a70a1 Mon Sep 17 00:00:00 2001 From: tim Date: Sun, 27 Oct 2024 23:45:00 -0400 Subject: [PATCH] IEEE754 isPositive/isNegative fixes --- src/core/IEEE754.sol | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/IEEE754.sol b/src/core/IEEE754.sol index 728c6ca..34c5099 100644 --- a/src/core/IEEE754.sol +++ b/src/core/IEEE754.sol @@ -63,11 +63,13 @@ library IEEE754 { }} function isPositive(float f) internal pure returns (bool) { - return float.unwrap(f) & SIGN_MASK == 0; + uint32 raw = float.unwrap(f); + return raw != 0 && raw & SIGN_MASK == 0; } function isNegative(float f) internal pure returns (bool) { - return float.unwrap(f) & SIGN_MASK != 0; + uint32 raw = float.unwrap(f); + return raw != 0 && raw & SIGN_MASK != 0; } function isZero(float f) internal pure returns (bool) {