Skip to content

Commit db99507

Browse files
authored
number:toString fixes (#3557)
Disallows nan and applies the fix suggested by Vurv If you we disallow nan, `self.prf`` will also become nan, which could likely cause problems/easily cause an infinite loop Fixes #3539
1 parent a34e816 commit db99507

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lua/entities/gmod_wire_expression2/core/number.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,10 +581,10 @@ __e2setcost(10)
581581
local CHARS = string.Split("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", "")
582582

583583
local function tobase(number, base, self)
584-
if base < 2 or base > 36 or number == 0 then return "0" end
584+
if base < 2 or base > 36 or base ~= base or number == 0 or number ~= number then return "0" end
585585
if base == 10 then return tostring(number) end
586586

587-
local out, loops, d = {}, ceil(log(number) / log(base)), 0
587+
local out, loops, d = {}, floor(log(number) / log(base)) + 1, 0
588588
if loops == inf then return "inf" end
589589

590590
for i = loops, 1, -1 do

0 commit comments

Comments
 (0)