Any way to have calculation with numbers bigger than 'inf'

Today I found a funny video of Tupper’s self-referential formula and I wanted to recreate that in roblox.
Everything whent fine, wikipedia had the formula ready to use. I just needed the number and I was set. BUT this number is 543 digits long. As far as I know lua turns numbers bigger than 300 (or something) digits into infinite. Is there any way around this?
I’ve tried using e but that still made it showup as inf.

Here’s the code I’m using if someone is interrested:

local function tuppers(x,y)
	return 1/2 < math.floor((math.floor(y/17)*2^(-17*math.floor(x)-(math.floor(y)%17))%2))
end

local start = 960939379918958884971672962127852754715004339660129306651505519271702802395266424689642842174350718121267153782770623355993237280874144307891325963941337723487857735749823926629715517173716995165232890538221612403238855866184013235585136048828693337902491454229288667081096184496091705183454067827731551705405381627380967602565625016981482083418783163849115590225610003652351370343874461848378737238198224849863465033159410054974700593138339226497249461751545728366702369745461014655997933798537483143786841806593422227898388722980000748404719

for x = 1,106 do
	for y = 1,17 do
		print(start)
		if tuppers(x,start+y) then
			local p = Instance.new("Part")
			p.Anchored = true
			p.Position = Vector3.new(x,y,0)
			p.Size = Vector3.new(1,1,1)
			p.Parent = workspace
		end
	end
	wait()
end

Lua numbers can be as large as ~1e300, but the actual precision is limited to around 17 decimal places. What you need is an arbitrary precision module. I believe there are some available on the Internet, if you do a search.

1 Like

You need to use arbitrary-precision library which allows you to work with big numbers.
For example, here is BigNum.lua library that I sometimes use:

To use it, insert return BigNum at the end to turn it into a module, and after requiring it use BigNum.new(number). Because it uses metatables, it works just like normal numbers would.

Edit: This library uses math.mod function, which does not exist in Rbx Lua, so you’d need to change it to % instead. Also, this library only supports integers, and because of that it automatically does floor operation on the number, so you need to remove math.floor from the formula.

5 Likes

This one is ported to Roblox

1 Like