Skip to content

Commit 435cd54

Browse files
committed
patch bug
+ fix calculate result is incorrect + fix `div` function
1 parent 60f73b6 commit 435cd54

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

int.lua

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-- ULTIMATE INT --
33
----------------------------------------------------
44
-- MODULE VERSION: 186
5-
-- BUILD VERSION: 186.6 (26/11/2025) dd:mm:yyyy
5+
-- BUILD VERSION: 186.6 (28/11/2025) dd:mm:yyyy
66
-- USER FEATURE: 26/11/2025
77
-- DEV FEATURE: 26/11/2025
88
-- AUTHOR: SupTan85
@@ -274,16 +274,15 @@ master.equation = {
274274
return false
275275
end,
276276
less = function(x, y) -- chunk size should be same
277+
-- BUILD 186.6
277278
assert((x._size or 1) == (y._size or 1), ("[EQUATION] INVALID_SIZE_PERCHUNK (%s, %s)"):format(x._size or 1, y._size or 1))
278279
if #x < #y then
279280
return true
280-
elseif #x == #y or x[#x] == 0 or y[#y] == 0 then
281-
for i = #x, x._dlen or 1, -1 do
281+
elseif #x == #y then
282+
for i = #x, min((x._dlen or 1), (y._dlen or 1)) or 1, -1 do
282283
local vx, vy = x[i] or 0, y[i] or 0
283-
if vx < vy then
284-
return true
285-
elseif vx > vy then
286-
return false
284+
if vx ~= vy then
285+
return vx < vy
287286
end
288287
end
289288
end
@@ -590,13 +589,13 @@ master.calculate = {
590589
local p = b == "1" and "1" or tostring("1" / b)
591590
if p:find("e") then
592591
local L, R = p:match("^[-+]?(%d-%.?%d+)e"), p:match("e[-+]?(%d+)$")
593-
L, lastpoint = L:sub(1, -2), L:sub(-2, -2)
594-
local S = #L:match("^(%d+)%.")
592+
L, lastpoint = #L > 1 and L:sub(1, -2) or L, #L > 1 and L:sub(-2, -2) or L
593+
local S = #L:match("^(%d+)%.?")
595594
if R > master._config.MAXIMUM_LUA_INTEGER then
596595
return {L:gsub("%.", ""), self.sub(masterC(R, s), masterC(S, s))}
597596
end
598-
return "0."..("0"):rep(tonumber(R) - S)..L:gsub("%.", ""):sub(1, -4)
599-
elseif p ~= "0.0" then
597+
return "0."..("0"):rep(tonumber(R) - S)..(#L > 1 and L:gsub("%.", ""):sub(1, -2) or L)
598+
elseif p ~= "0.0" and p ~= "0" then
600599
lastpoint = p:sub(-1)
601600
if #p > 13 then
602601
p = p:sub(1, -2)

testsuite.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,16 @@ end
149149
if not suite_select or suite_select == 1 then
150150
print("\nUsing CheckAccuracy-Suite")
151151
benchmark("add, sub", function(x, y)
152+
-- print(1,(x + y))
153+
-- print(2,(x + y) - x)
154+
-- print(3,((x + y) - x) - y)
152155
return ((x + y) - x) - y
153156
end, farg)
154157

155158
benchmark("sub, mul, div", function(x, y)
159+
-- print(1,x / y)
160+
-- print(2,(x / y) * y)
161+
-- print(3,x - ((x / y) * y))
156162
return x - ((x / y) * y)
157163
end, farg)
158164
end

0 commit comments

Comments
 (0)