mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-10-15 05:07:24 +00:00
Remove situations where we're comparing floats with == (Fixes #819)
This commit is contained in:
@@ -134,7 +134,7 @@ def compile(file, defines = [])
|
|||||||
if $cfg[:tools][:test_compiler][:executable] =~ /gcc/
|
if $cfg[:tools][:test_compiler][:executable] =~ /gcc/
|
||||||
$cfg[:tools][:test_compiler][:arguments] |= ['-Wno-misleading-indentation']
|
$cfg[:tools][:test_compiler][:arguments] |= ['-Wno-misleading-indentation']
|
||||||
end
|
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)
|
execute(cmd_str)
|
||||||
out_file
|
out_file
|
||||||
end
|
end
|
||||||
|
|||||||
+8
-4
@@ -445,13 +445,17 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* round to nearest integer */
|
/* 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
|
#ifndef UNITY_ROUND_TIES_AWAY_FROM_ZERO
|
||||||
/* round to even if exactly between two integers */
|
/* round to even if exactly between two integers */
|
||||||
if ((n & 1) && (UNITY_ABS((UNITY_DOUBLE)n - number - 0.5f) < epsilon))
|
if ((n & 1) && (two_n_trunc & 1) && !((UNITY_DOUBLE)two_n_trunc < two_number))
|
||||||
n--;
|
n--;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
n += n_int;
|
n += n_int;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user