mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-12-17 05:54:07 +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
|
else
|
||||||
{
|
{
|
||||||
UNITY_INT32 n_int = 0, n;
|
UNITY_INT32 n_int = 0;
|
||||||
int exponent = 0;
|
UNITY_INT32 n;
|
||||||
int decimals, digits;
|
int exponent = 0;
|
||||||
char buf[16] = {0};
|
int decimals;
|
||||||
|
int digits;
|
||||||
|
char buf[16] = {0};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Scale up or down by powers of 10. To minimize rounding error,
|
* 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 */
|
/* build up buffer in reverse order */
|
||||||
digits = 0;
|
digits = 0;
|
||||||
while ((n != 0) || (digits < (decimals + 1)))
|
while ((n != 0) || (digits <= decimals))
|
||||||
{
|
{
|
||||||
buf[digits++] = (char)('0' + n % 10);
|
buf[digits++] = (char)('0' + n % 10);
|
||||||
n /= 10;
|
n /= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* print out buffer (backwards) */
|
||||||
while (digits > 0)
|
while (digits > 0)
|
||||||
{
|
{
|
||||||
if (digits == decimals) { UNITY_OUTPUT_CHAR('.'); }
|
if (digits == decimals)
|
||||||
|
{
|
||||||
|
UNITY_OUTPUT_CHAR('.');
|
||||||
|
}
|
||||||
UNITY_OUTPUT_CHAR(buf[--digits]);
|
UNITY_OUTPUT_CHAR(buf[--digits]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user