Print small floats instead of 0 by APX403 · Pull Request #856 · ThrowTheSwitch/Unity · GitHub
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
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