mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-12-16 20:51:17 +08:00
Remove "error: assuming signed overflow does not occur when reducing constant in comparison [-Werror=strict-overflow]"
This commit is contained in:
19
src/unity.c
19
src/unity.c
@@ -369,10 +369,12 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
|
||||
}
|
||||
else
|
||||
{
|
||||
UNITY_INT32 n_int = 0, n;
|
||||
int exponent = 0;
|
||||
int decimals, digits;
|
||||
char buf[16] = {0};
|
||||
UNITY_INT32 n_int = 0;
|
||||
UNITY_INT32 n;
|
||||
int exponent = 0;
|
||||
int decimals;
|
||||
int digits;
|
||||
char buf[16] = {0};
|
||||
|
||||
/*
|
||||
* Scale up or down by powers of 10. To minimize rounding error,
|
||||
@@ -445,14 +447,19 @@ void UnityPrintFloat(const UNITY_DOUBLE input_number)
|
||||
|
||||
/* build up buffer in reverse order */
|
||||
digits = 0;
|
||||
while ((n != 0) || (digits < (decimals + 1)))
|
||||
while ((n != 0) || (digits <= decimals))
|
||||
{
|
||||
buf[digits++] = (char)('0' + n % 10);
|
||||
n /= 10;
|
||||
}
|
||||
|
||||
/* print out buffer (backwards) */
|
||||
while (digits > 0)
|
||||
{
|
||||
if (digits == decimals) { UNITY_OUTPUT_CHAR('.'); }
|
||||
if (digits == decimals)
|
||||
{
|
||||
UNITY_OUTPUT_CHAR('.');
|
||||
}
|
||||
UNITY_OUTPUT_CHAR(buf[--digits]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user