From cf37d9d6620a3bb3ce814f6d50b8fd8e7b0b4743 Mon Sep 17 00:00:00 2001 From: Astralcircle <142503363+Astralcircle@users.noreply.github.com> Date: Tue, 17 Mar 2026 01:01:44 +0300 Subject: [PATCH] number:toString fixes 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 --- lua/entities/gmod_wire_expression2/core/number.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/number.lua b/lua/entities/gmod_wire_expression2/core/number.lua index 3dcb8ef23d..7cca6799a4 100644 --- a/lua/entities/gmod_wire_expression2/core/number.lua +++ b/lua/entities/gmod_wire_expression2/core/number.lua @@ -581,10 +581,10 @@ __e2setcost(10) local CHARS = string.Split("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ", "") local function tobase(number, base, self) - if base < 2 or base > 36 or number == 0 then return "0" end + if base < 2 or base > 36 or base ~= base or number == 0 or number ~= number then return "0" end if base == 10 then return tostring(number) end - local out, loops, d = {}, ceil(log(number) / log(base)), 0 + local out, loops, d = {}, floor(log(number) / log(base)) + 1, 0 if loops == inf then return "inf" end for i = loops, 1, -1 do