Remove situations where we're comparing floats with == (Fixes #819)

This commit is contained in:
Mark VanderVoord
2026-07-06 14:47:41 -04:00
parent a3b703b4d9
commit 41d6933b39
2 changed files with 9 additions and 5 deletions
+1 -1
View File
@@ -134,7 +134,7 @@ def compile(file, defines = [])
if $cfg[:tools][:test_compiler][:executable] =~ /gcc/
$cfg[:tools][:test_compiler][:arguments] |= ['-Wno-misleading-indentation']
end
cmd_str = build_command_string($cfg[:tools][:test_compiler], [file, out_file], defines)
cmd_str = build_command_string($cfg[:tools][:test_compiler], [file, out_file], defines)
execute(cmd_str)
out_file
end
+8 -4
View File
@@ -445,13 +445,17 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
}
/* round to nearest integer */
n = ((UNITY_INT32)(number + number) + 1) / 2;
{
UNITY_DOUBLE two_number = number + number;
UNITY_INT32 two_n_trunc = (UNITY_INT32)two_number;
n = (two_n_trunc + 1) / 2;
#ifndef UNITY_ROUND_TIES_AWAY_FROM_ZERO
/* round to even if exactly between two integers */
if ((n & 1) && (UNITY_ABS((UNITY_DOUBLE)n - number - 0.5f) < epsilon))
n--;
/* round to even if exactly between two integers */
if ((n & 1) && (two_n_trunc & 1) && !((UNITY_DOUBLE)two_n_trunc < two_number))
n--;
#endif
}
n += n_int;