mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-06-18 12:51:44 +08:00
A (hopefully) more universal fix for the signed max negative value printer
This commit is contained in:
16
src/unity.c
16
src/unity.c
@ -125,18 +125,24 @@ void UnityPrintNumber(const _U_SINT number_to_print)
|
|||||||
{
|
{
|
||||||
_U_SINT divisor = 1;
|
_U_SINT divisor = 1;
|
||||||
_U_SINT next_divisor;
|
_U_SINT next_divisor;
|
||||||
|
|
||||||
_U_UINT number;
|
_U_UINT number;
|
||||||
|
|
||||||
if (number_to_print < 0)
|
if (number_to_print == (1l << (UNITY_LONG_WIDTH-1)))
|
||||||
{
|
{
|
||||||
|
//The largest representable negative number
|
||||||
UNITY_OUTPUT_CHAR('-');
|
UNITY_OUTPUT_CHAR('-');
|
||||||
number = -number_to_print;
|
number = (_U_UINT)number_to_print;
|
||||||
|
}
|
||||||
|
else if (number_to_print < 0)
|
||||||
|
{
|
||||||
|
//Some other negative number
|
||||||
|
UNITY_OUTPUT_CHAR('-');
|
||||||
|
number = (_U_UINT)(-number_to_print);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
number = number_to_print;
|
//Positive number
|
||||||
|
number = (_U_UINT)number_to_print;
|
||||||
}
|
}
|
||||||
|
|
||||||
// figure out initial divisor
|
// figure out initial divisor
|
||||||
|
Reference in New Issue
Block a user