Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/UnityChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Significant Bugfixes:

- Default `UNITY_INCLUDE_EXEC_TIME` macros compile as ISO C99, are statement-safe, and accept `-Wsign-conversion` (#838)
- `unity_test_summary.rb` honors its own default result directory and root path again. @youdie006
- Floats and doubles smaller than `UNITY_FLOAT_PRECISION` or `UNITY_DOUBLE_PRECISION` print as their value again instead of `0`. @APX403

### Unity 2.7.0 (July 2026)

Expand Down
4 changes: 1 addition & 3 deletions src/unity.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,18 +367,16 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
static const int sig_digits = 9;
static const UNITY_INT32 min_scaled = 100000000;
static const UNITY_INT32 max_scaled = 1000000000;
static const UNITY_DOUBLE epsilon = UNITY_DOUBLE_PRECISION;
#else
static const int sig_digits = 7;
static const UNITY_INT32 min_scaled = 1000000;
static const UNITY_INT32 max_scaled = 10000000;
static const UNITY_DOUBLE epsilon = UNITY_FLOAT_PRECISION;
#endif

UNITY_DOUBLE number = input_number;

/* handle zero, NaN, and +/- infinity */
if (UNITY_ABS(number) < epsilon)
if ((number >= 0.0f) && (number <= 0.0f))
{
UnityPrint("0");
}
Expand Down
4 changes: 4 additions & 0 deletions test/tests/test_unity_doubles.c
Original file line number Diff line number Diff line change
Expand Up @@ -1249,11 +1249,15 @@ void testDoublePrinting(void)
TEST_ASSERT_EQUAL_PRINT_FLOATING("7e+100", 7.0e+100);
TEST_ASSERT_EQUAL_PRINT_FLOATING("3e+200", 3.0e+200);
TEST_ASSERT_EQUAL_PRINT_FLOATING("9.23456789e+300", 9.23456789e+300);
TEST_ASSERT_EQUAL_PRINT_FLOATING("4.99e-13", 4.99e-13);
TEST_ASSERT_EQUAL_PRINT_FLOATING("7e-100", 7.0e-100);

TEST_ASSERT_EQUAL_PRINT_FLOATING("-0.1004695", -0.10046949999999999);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.2949673e+09", -4294967295.9);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.2949673e+09", -4294967296.0);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-7e+100", -7.0e+100);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-4.99e-13", -4.99e-13);
TEST_ASSERT_EQUAL_PRINT_FLOATING("-7e-100", -7.0e-100);
#endif
}

Expand Down