1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Fix the digit counting helpers to take into account negative values.

This commit is contained in:
Sandu Liviu Catalin 2016-04-14 04:50:44 +03:00
parent 4504ae0550
commit 1017fc5c1a

View File

@ -1075,7 +1075,7 @@ static SQInteger SqDigits1(HSQUIRRELVM vm)
return sq_throwerror(vm, "Wrong number of arguments"); return sq_throwerror(vm, "Wrong number of arguments");
} }
// Fetch the integer value from the stack // Fetch the integer value from the stack
Int64 n = PopStackLong(vm, 2); Int64 n = std::llabs(PopStackLong(vm, 2));
// Start with 0 digits // Start with 0 digits
Uint8 d = 0; Uint8 d = 0;
// Identify the number of digits // Identify the number of digits
@ -1099,7 +1099,7 @@ static SQInteger SqDigits0(HSQUIRRELVM vm)
return sq_throwerror(vm, "Wrong number of arguments"); return sq_throwerror(vm, "Wrong number of arguments");
} }
// Fetch the integer value from the stack // Fetch the integer value from the stack
Int64 n = PopStackLong(vm, 2); Int64 n = std::llabs(PopStackLong(vm, 2));
// Start with 0 digits // Start with 0 digits
Uint8 d = 0; Uint8 d = 0;
// Identify the number of digits // Identify the number of digits