From c135d4293edd85be2bfd72c33a65d539db48d401 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Mon, 23 May 2016 05:39:32 +0300 Subject: [PATCH] Remove irrelevant argument from the IToF function. --- source/Library/Math.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/source/Library/Math.cpp b/source/Library/Math.cpp index 49ec51cb..b1629b2d 100644 --- a/source/Library/Math.cpp +++ b/source/Library/Math.cpp @@ -1115,22 +1115,19 @@ static SQInteger SqDigits0(HSQUIRRELVM vm) } // ------------------------------------------------------------------------------------------------ -SQFloat SqIToF(Int64 sigv, Int64 expv, Int32 padn, Int32 padc, bool negf) +SQFloat SqIToF(Int64 sigv, Int64 expv, Int32 padn, bool negf) { // The number of characters to add before the exponent static CharT padb[64]; + // Make sure the pad number is positive + padn = ClampMin(padn, 0); // Is the number of pad characters out of range? - if (padn >= 64) + if (static_cast< Uint32 >(padn) >= sizeof(padb)) { - STHROWF("Pad characters out of range: %d >= 64", padn); - } - // Is the pad character invalid? - else if (padc > 9 || padc < 0) - { - STHROWF("Invalid padding value: %d", padc); + STHROWF("Pad characters out of range: %d >= %d", padn, sizeof(padb)); } // Write the padding characters - std::memset(padb, 48 + padc, padn); + std::memset(padb, '0', padn); // Add the null terminator padb[padn] = '\0'; // The obtained string containing the floating point