diff --git a/src/unity.c b/src/unity.c index 9b80605e53bd3506bed4b93a4c3e1583427f14ad..1b5579146121dc6b7124139d12559e5ca6022dbf 100644 --- a/src/unity.c +++ b/src/unity.c @@ -429,14 +429,14 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number) UNITY_DOUBLE number = input_number; /* print minus sign (including for negative zero) */ - if ((number < 0.0f) || ((number == 0.0f) && ((1.0f / number) < 0.0f))) + if (number < 0.0f) { UNITY_OUTPUT_CHAR('-'); number = -number; } /* handle zero, NaN, and +/- infinity */ - if (number == 0.0f) + if (number == 0.0f) { UnityPrint("0"); } diff --git a/test/tests/testunity.c b/test/tests/testunity.c index 2771a995f0f39cd96a5c425834176ec901620d0b..c9712eda2139d0d5b85e845ce35f484c93d4d8ea 100644 --- a/test/tests/testunity.c +++ b/test/tests/testunity.c @@ -7722,7 +7722,7 @@ void testDoublePrinting(void) TEST_ASSERT_EQUAL_PRINT_FLOATING("16.0000006", 16.0000006); TEST_ASSERT_EQUAL_PRINT_FLOATING("999999999", 999999999.0); /*Last full print integer*/ - TEST_ASSERT_EQUAL_PRINT_FLOATING("-0", -0.0); + TEST_ASSERT_EQUAL_PRINT_FLOATING("0", -0.0); /* -0 no supported on all targets */ TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.99e-07", -0.000000499); TEST_ASSERT_EQUAL_PRINT_FLOATING("-5.0000005e-07", -0.00000050000005); TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.100469499", -0.100469499);