Skip to content

Commit 1828d66

Browse files
committed
fix 2+ ante scaling breaking on e308 limit
1 parent 3873424 commit 1828d66

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

big-num/bignumber.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ R.MAX_DISP_INTEGER=1000000
370370
R.NaN=0/0
371371
R.NEGATIVE_INFINITY = -1/0
372372
R.POSITIVE_INFINITY = 1/0
373-
R.E_MAX_SAFE_INTEGER="e"..tostring(R.MAX_SAFE_INTEGER)
373+
R and R.E_MAX_SAFE_INTEGER or 9e15="e"..tostring(R.MAX_SAFE_INTEGER)
374374
R.EE_MAX_SAFE_INTEGER="ee"..tostring(R.MAX_SAFE_INTEGER)
375375
R.TETRATED_MAX_SAFE_INTEGER="10^^"..tostring(R.MAX_SAFE_INTEGER)
376376

big-num/omeganum.lua

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ R.MAX_DISP_INTEGER=1000000
3838
R.NaN=0/0
3939
R.NEGATIVE_INFINITY = -1/0
4040
R.POSITIVE_INFINITY = 1/0
41-
R.E_MAX_SAFE_INTEGER="e"..tostring(R.MAX_SAFE_INTEGER)
41+
R and R.E_MAX_SAFE_INTEGER or 9e15="e"..tostring(R.MAX_SAFE_INTEGER)
4242
R.EE_MAX_SAFE_INTEGER="ee"..tostring(R.MAX_SAFE_INTEGER)
4343
R.TETRATED_MAX_SAFE_INTEGER="10^^"..tostring(R.MAX_SAFE_INTEGER)
4444

@@ -613,15 +613,15 @@ function Big:add(other)
613613
local p=x:min(other);
614614
local q=x:max(other);
615615
local t = -1;
616-
if (p.array[2] == 2) and not p:gt(R.E_MAX_SAFE_INTEGER) then
616+
if (p.array[2] == 2) and not p:gt(R and R.E_MAX_SAFE_INTEGER or 9e15) then
617617
p.array[2] = 1
618618
p.array[1] = 10 ^ p.array[1]
619619
end
620-
if (q.array[2] == 2) and not q:gt(R.E_MAX_SAFE_INTEGER) then
620+
if (q.array[2] == 2) and not q:gt(R and R.E_MAX_SAFE_INTEGER or 9e15) then
621621
q.array[2] = 1
622622
q.array[1] = 10 ^ q.array[1]
623623
end
624-
if (q:gt(R.E_MAX_SAFE_INTEGER) or q:div(p):gt(R.MAX_SAFE_INTEGER)) then
624+
if (q:gt(R and R.E_MAX_SAFE_INTEGER or 9e15) or q:div(p):gt(R.MAX_SAFE_INTEGER)) then
625625
t = q;
626626
elseif (q.array[2] == nil) or (q.array[2] == 0) then
627627
t= Big:create(x:to_number()+other:to_number());
@@ -667,15 +667,15 @@ function Big:sub(other)
667667
local q = x:max(other);
668668
local n = other:gt(x);
669669
local t = -1;
670-
if (p.array[2] == 2) and not p:gt(R.E_MAX_SAFE_INTEGER) then
670+
if (p.array[2] == 2) and not p:gt(R and R.E_MAX_SAFE_INTEGER or 9e15) then
671671
p.array[2] = 1
672672
p.array[1] = 10 ^ p.array[1]
673673
end
674-
if (q.array[2] == 2) and not q:gt(R.E_MAX_SAFE_INTEGER) then
674+
if (q.array[2] == 2) and not q:gt(R and R.E_MAX_SAFE_INTEGER or 9e15) then
675675
q.array[2] = 1
676676
q.array[1] = 10 ^ q.array[1]
677677
end
678-
if (q:gt(R.E_MAX_SAFE_INTEGER) or q:div(p):gt(R.MAX_SAFE_INTEGER)) then
678+
if (q:gt(R and R.E_MAX_SAFE_INTEGER or 9e15) or q:div(p):gt(R.MAX_SAFE_INTEGER)) then
679679
t = q;
680680
if n then
681681
t = t:neg()
@@ -1057,7 +1057,7 @@ function Big:tetrate(other)
10571057
local r = t:pow(y-f)
10581058
local l = Big:create(R.NaN)
10591059
local i = 0
1060-
local m = Big:create(R.E_MAX_SAFE_INTEGER)
1060+
local m = Big:create(R and R.E_MAX_SAFE_INTEGER or 9e15)
10611061
while ((f ~= 0) and r:lt(m) and (i < 100)) do
10621062
if (f > 0) then
10631063
r = t:pow(r)
@@ -1188,7 +1188,7 @@ function Big:lambertw()
11881188
x.array[1] = x.array[1] - 1
11891189
return x;
11901190
end
1191-
if (x:gt(R.E_MAX_SAFE_INTEGER)) then
1191+
if (x:gt(R and R.E_MAX_SAFE_INTEGER or 9e15)) then
11921192
return Big:d_lambertw(x)
11931193
else
11941194
return Big:create(Big:f_lambertw(x.sign*x.array[1]))

talisman.lua

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -240,20 +240,20 @@ function lenient_bignum(x)
240240
if ante < 1 then return to_big(100) end
241241
if ante <= 8 then
242242
local amount = amounts[ante]
243-
if (amount:lt(R.E_MAX_SAFE_INTEGER)) then
244-
local exponent = to_big(10)^(math.floor(amount:log10() - to_big(1))):to_number()
245-
amount = math.floor(amount / exponent):to_number() * exponent
243+
if to_big(amount) < to_big(R and R.E_MAX_SAFE_INTEGER or 9e15) then
244+
local exponent = to_big(10)^to_number(math.floor(math.log(amount, 10) - to_big(1)))
245+
amount = to_number(math.floor(amount / exponent)) * exponent
246246
end
247-
amount:normalize()
247+
if type(amount) == "table" then amount:normalize() end
248248
return amount
249249
end
250250
local a, b, c, d = amounts[8], amounts[8]/amounts[7], ante-8, 1 + 0.2*(ante-8)
251251
local amount = math.floor(a*(b + (b*k*c)^d)^c)
252-
if (amount:lt(R.E_MAX_SAFE_INTEGER)) then
253-
local exponent = to_big(10)^(math.floor(amount:log10() - to_big(1))):to_number()
254-
amount = math.floor(amount / exponent):to_number() * exponent
252+
if to_big(amount) < to_big(R and R.E_MAX_SAFE_INTEGER or 9e15) then
253+
local exponent = to_big(10)^to_number(math.floor(math.log(amount, 10) - to_big(1)))
254+
amount = to_number(math.floor(amount / exponent)) * exponent
255255
end
256-
amount:normalize()
256+
if type(amount) == "table" then amount:normalize() end
257257
return amount
258258
end
259259
end
@@ -272,11 +272,11 @@ function lenient_bignum(x)
272272
if ante <= 8 then return amounts[ante] end
273273
local a, b, c, d = amounts[8],1.6,ante-8, 1 + 0.2*(ante-8)
274274
local amount = a*(b+(k*c)^d)^c
275-
if (amount:lt(R.E_MAX_SAFE_INTEGER)) then
276-
local exponent = to_big(10)^(math.floor(amount:log10() - to_big(1))):to_number()
277-
amount = math.floor(amount / exponent):to_number() * exponent
275+
if to_big(amount) < to_big(R and R.E_MAX_SAFE_INTEGER or 9e15) then
276+
local exponent = to_big(10)^to_number(math.floor(math.log(amount, 10) - to_big(1)))
277+
amount = to_number(math.floor(amount / exponent)) * exponent
278278
end
279-
amount:normalize()
279+
if type(amount) == "table" then amount:normalize() end
280280
return amount
281281
elseif G.GAME.modifiers.scaling == 2 then
282282
local amounts = {
@@ -287,11 +287,11 @@ function lenient_bignum(x)
287287
if ante <= 8 then return amounts[ante] end
288288
local a, b, c, d = amounts[8],1.6,ante-8, 1 + 0.2*(ante-8)
289289
local amount = a*(b+(k*c)^d)^c
290-
if (amount:lt(R.E_MAX_SAFE_INTEGER)) then
291-
local exponent = to_big(10)^(math.floor(amount:log10() - to_big(1))):to_number()
292-
amount = math.floor(amount / exponent):to_number() * exponent
290+
if to_big(amount) < to_big(R and R.E_MAX_SAFE_INTEGER or 9e15) then
291+
local exponent = to_big(10)^to_number(math.floor(math.log(amount, 10) - to_big(1)))
292+
amount = to_number(math.floor(amount / exponent)) * exponent
293293
end
294-
amount:normalize()
294+
if type(amount) == "table" then amount:normalize() end
295295
return amount
296296
elseif G.GAME.modifiers.scaling == 3 then
297297
local amounts = {
@@ -302,11 +302,11 @@ function lenient_bignum(x)
302302
if ante <= 8 then return amounts[ante] end
303303
local a, b, c, d = amounts[8],1.6,ante-8, 1 + 0.2*(ante-8)
304304
local amount = a*(b+(k*c)^d)^c
305-
if (amount:lt(R.E_MAX_SAFE_INTEGER)) then
306-
local exponent = to_big(10)^(math.floor(amount:log10() - to_big(1))):to_number()
307-
amount = math.floor(amount / exponent):to_number() * exponent
305+
if to_big(amount) < to_big(R and R.E_MAX_SAFE_INTEGER or 9e15) then
306+
local exponent = to_big(10)^to_number(math.floor(math.log(amount, 10) - to_big(1)))
307+
amount = to_number(math.floor(amount / exponent)) * exponent
308308
end
309-
amount:normalize()
309+
if type(amount) == "table" then amount:normalize() end
310310
return amount
311311
end
312312
end

0 commit comments

Comments
 (0)