Number to string with EternityNum help

So, I want my game to use EternityNum, But it currently relies on normal roblox limits, But i want my game to go past the regular limits in where EternityNum takes place, As EternityNum will allow numbers up to 10^^(2^1024) where ^^ is a tetration
The Eternity.Short function will return a suffix, But the .short will rely on strings since strings have no limit.

Code to get converted to string

Client:

local button = script.Parent.Button
local ts = game:GetService("TweenService")
local count = 0
local cooldownActive = false
local highScore = 0
local resetMoney = 0
local RS = game:GetService("ReplicatedStorage")
local shop = script.Parent.Shop.ScrollingFrame
local cooldown = script.Parent.Cooldown
local moneymulti = script.Parent.MoneyMultiplier
local countmulti = script.Parent.CountMultiplier
local Eternity = require(RS.EternityNum)
local maid = require(RS.DeviceMaid)
local platform = maid:getPlatform()
local Suffixes = {"K", "M", "B", "T", "QD", "QN", "SX", "SP", "O", "N", "DE", "UD", "DD", "TD", "QDD", "QND", "SXD", "SPD", "OCD", "NVD", "VG", "UVG", "DVG", "TVG", "QTV", "QNV", "SEV", "SPV", "OVG", "NVG", "TG", "UTG", "DTG", "TSTG", "QDTG", "QNTG", "SSTG", "SPTG", "OCTG", "NVTG", "QDDR", "UQDR", "DQDR", "TQDR", "QDQDR", "QNQDR", "SXQDR", "SPQDR", "OQDDR", "NQDDR", "QQGNT", "UQGNT", "DQGNT", "TQGNT", "QDQGNT", "QNQGNT", "SXQGNT", "SPQGNT", "OQQGNT", "NQQGNT", "SXGNTL", "USXGNTL", "DSXGNTL", "TSXGNTL", "QTSXGNTL", "QNSXGNTL", "SXSXGNTL", "SPSXGNTL", "OSXGNTL", "NVSXGNTL", "SPTGNTL", "USPTGNTL", "DSPTGNTL", "TSPTGNTL", "QTSPTGNTL", "QNSPTGNTL", "SXSPTGNTL", "SPSPTGNTL", "OSPTGNTL", "NVSPTGNTL", "OTGNTL", "UOTGNTL", "DOTGNTL", "TOTGNTL", "QTOTGNTL", "QNOTGNTL", "SXOTGNTL", "SPOTGNTL", "OTOTGNTL", "NVOTGNTL", "NONGNTL", "UNONGNTL", "DNONGNTL", "TNONGNTL", "QTNONGNTL", "QNNONGNTL", "SXNONGNTL","SPNONGNTL", "OTNONGNTL", "NONONGNTL", "CENT", "UNCENT", "DCENT", "TCENT", "QTCENT", "QNCENT", "SXCENT", "SPCENT", "OCCENT", "NVCENT"}

function Convert(Input)
	local Negative = Input < 0
	Input = math.abs(Input)

	local Paired = false
	for i, v in pairs(Suffixes) do
		if not (Input >= 10 ^ (3 * i)) then
			Input = Input / 10 ^ (3 * (i - 1))
			local isComplex = (string.find(tostring(Input), ".") and string.sub(tostring(Input), 4, 4) ~= ".")
			Input = string.sub(tostring(Input), 1, (isComplex and 4) or 3) .. (Suffixes[i - 1] or "")
			Paired = true
			break
		end
	end

	if not Paired then
		local Rounded = math.floor(Input)
		Input = tostring(Rounded)
	end

	if Negative then
		return "-" .. Input
	end

	return Input
end

function ScientificToNumber(scientificNotation)
	local coefficient, exponent = scientificNotation:match("([%d.]+)e([%+%-]?%d+)")
	if coefficient and exponent then
		return Convert(tonumber(coefficient) * 10^exponent)
	else
		return nil
	end
end
button.Text = Convert(count)

if platform=="Mobile" then
	button.Size=UDim2.fromScale(0.5,0.214)
	button.Parent.Shadow.Size=UDim2.fromScale(0.5,0.225)
else
	button.Size=UDim2.fromScale(0.125,0.214)
	button.Parent.Shadow.Size=UDim2.fromScale(0.125,0.225)
end

local function RoundUp(Number:number,Decimals:number)
	return math.round(Number*(10*Decimals))/(10*Decimals)
end

local function SetText()
	button.Text = Convert(count)
	if count ~= 0 then
		script.Parent.ChanceText.Text = "CHANCE TO RESET: 1/" .. Convert(RoundUp(((100*countmulti.Value)/count),1))
	else
		script.Parent.ChanceText.Text = "CHANCE TO RESET: 1/" .. Convert((100*countmulti.Value))
	end
end

local function UpdateHighScore()
	resetMoney+=count*moneymulti.Value
	RS.UpdateStats:FireServer("ResetMoney", resetMoney)
	script.Parent.ResetMoneyText.Text = "RESET MONEY: " .. Convert(resetMoney)
	if count > highScore then
		highScore = count
		RS.UpdateStats:FireServer("HighScore", highScore)
		script.Parent.HighScoreText.Text = "HIGH SCORE: " .. Convert(highScore)
	end
end

local function handleClick()
	if cooldownActive then
		return
	else
		cooldownActive = true
		ts:Create(button, TweenInfo.new(0.1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Position = UDim2.fromScale(0.575, 0.51)}):Play()
		count += 1 * countmulti.Value
		local rand = math.round(Random.new():NextNumber(1,RoundUp(((100*countmulti.Value)/count),1)))
		print(rand)
		SetText()
		if rand <= 1 then
			UpdateHighScore()
			count = 0
			SetText()
			task.wait(cooldown.Value)
		else
			task.wait(cooldown.Value)
			ts:Create(button, TweenInfo.new(0.1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Position = UDim2.fromScale(0.575, 0.5)}):Play()
		end
		RS.UpdateStats:FireServer("Score", count)
		cooldownActive = false
	end
end

button.Activated:Connect(handleClick)
coroutine.resume(coroutine.create(function()
	while task.wait(1/script.Parent.AutoClickerSpeed.Value) do
		if script.Parent.HasAutoClicker.Value then
			handleClick()
		end
	end
end))
shop.Cooldown.BuyButton.Activated:Connect(function()
	if script.Parent.ResetMoney.Value>=shop.Cooldown.Price.Value then
		resetMoney-=shop.Cooldown.Price.Value
		script.Parent.ResetMoneyText.Text = "RESET MONEY: " .. Convert(RoundUp(resetMoney, 1))
		RS.UpdateStats:FireServer("ResetMoney", resetMoney)
		RS.UpgradePurchase:FireServer("Cooldown", true)
		task.wait(0.1)
		shop.Cooldown.BuyButton.Text="BUY: "..Convert(RoundUp(shop.Cooldown.Price.Value, 10)).." RESET MONEY"
		shop.Cooldown.Increment.Text=tostring(RoundUp(cooldown.Value, 1000)).." > "..tostring(RoundUp(cooldown.Value*0.9, 1000))
	end
end)
shop.CountMulti.BuyButton.Activated:Connect(function()
	if script.Parent.ResetMoney.Value>=shop.CountMulti.Price.Value then
		resetMoney-=shop.CountMulti.Price.Value
		script.Parent.ResetMoneyText.Text = "RESET MONEY: " .. Convert(RoundUp(resetMoney, 1))
		RS.UpdateStats:FireServer("ResetMoney", resetMoney)
		RS.UpgradePurchase:FireServer("CountMulti", true)
		task.wait(0.1)
		shop.CountMulti.BuyButton.Text="BUY: "..Convert(RoundUp(shop.CountMulti.Price.Value, 10)).." RESET MONEY"
		shop.CountMulti.Increment.Text=Convert(RoundUp(countmulti.Value, 1000)).." > "..Convert(RoundUp(countmulti.Value+1, 1000))
	end
end)
shop.MoneyMulti.BuyButton.Activated:Connect(function()
	if script.Parent.ResetMoney.Value>=shop.MoneyMulti.Price.Value then
		resetMoney-=shop.MoneyMulti.Price.Value
		script.Parent.ResetMoneyText.Text = "RESET MONEY: " .. Convert(RoundUp(resetMoney, 1))
		RS.UpdateStats:FireServer("ResetMoney", resetMoney)
		RS.UpgradePurchase:FireServer("MoneyMulti", true)
		task.wait(0.1)
		shop.MoneyMulti.BuyButton.Text="BUY: "..Convert(RoundUp(shop.MoneyMulti.Price.Value, 10)).." RESET MONEY"
		shop.MoneyMulti.Increment.Text=Convert(RoundUp(moneymulti.Value, 1000)).." > "..Convert(RoundUp(moneymulti.Value*1.1, 1000))
	end
end)
shop.AutoClicker.BuyButton.Activated:Connect(function()
	if script.Parent.ResetMoney.Value>=shop.AutoClicker.Price.Value then
		resetMoney-=shop.AutoClicker.Price.Value
		script.Parent.ResetMoneyText.Text = "RESET MONEY: " .. Convert(RoundUp(resetMoney, 1))
		RS.UpdateStats:FireServer("ResetMoney", resetMoney)
		RS.UpgradePurchase:FireServer("AutoClicker", true)
		task.wait(0.1)
		shop.AutoClicker.BuyButton.Text="BUY: "..Convert(RoundUp(shop.AutoClicker.Price.Value, 10)).." RESET MONEY"
		shop.AutoClicker.Increment.Text=Convert(RoundUp(script.Parent.AutoClickerSpeed.Value, 1000)).." > "..Convert(RoundUp(script.Parent.AutoClickerSpeed.Value+1, 1000))
	end
end)
shop.BuyAutoClicker.BuyButton.Activated:Connect(function()
	if script.Parent.ResetMoney.Value>=shop.BuyAutoClicker.Price.Value then
		resetMoney-=shop.BuyAutoClicker.Price.Value
		script.Parent.ResetMoneyText.Text = "RESET MONEY: " .. Convert(RoundUp(resetMoney, 1))
		RS.UpdateStats:FireServer("ResetMoney", resetMoney)
		RS.UpgradePurchase:FireServer("BuyAutoClicker", true)
		task.wait(0.1)
		shop.BuyAutoClicker.BuyButton.Text="BUY: "..Convert(RoundUp(shop.BuyAutoClicker.Price.Value, 10)).." RESET MONEY"
		shop.BuyAutoClicker.Increment.Text=Convert(RoundUp(moneymulti.Value, 1000)).." > "..Convert(RoundUp(moneymulti.Value*2, 1000))
	end
end)

Server:

local RS = game:GetService("ReplicatedStorage")
RS.UpdateStats.OnServerEvent:Connect(function(plr, stattype:string, amt:number)
	if stattype=="Score" then
		plr.PlayerGui.ButtonUI.Score.Value=amt
	elseif stattype=="HighScore" then
		plr.PlayerGui.ButtonUI.HighScore.Value=amt
	elseif stattype=="ResetMoney" then
		plr.PlayerGui.ButtonUI.ResetMoney.Value=amt
	end
end)
RS.UpgradePurchase.OnServerEvent:Connect(function(plr, sort, buyable:boolean)
	if buyable then
		if sort=="Cooldown" then
			plr.PlayerGui.ButtonUI.Cooldown.Value*=0.9
			plr.PlayerGui.ButtonUI.Shop.ScrollingFrame.Cooldown.Price.Value*=1.5
		elseif sort=="CountMulti" then
			plr.PlayerGui.ButtonUI.CountMultiplier.Value+=1
			plr.PlayerGui.ButtonUI.Shop.ScrollingFrame.CountMulti.Price.Value*=2
		elseif sort=="MoneyMulti" then
			plr.PlayerGui.ButtonUI.MoneyMultiplier.Value*=1.1
			plr.PlayerGui.ButtonUI.Shop.ScrollingFrame.MoneyMulti.Price.Value*=3
		elseif sort=="AutoClicker" then
			plr.PlayerGui.ButtonUI.AutoClickerSpeed.Value+=1
			plr.PlayerGui.ButtonUI.Shop.ScrollingFrame.AutoClicker.Price.Value*=5
		elseif sort=="BuyAutoClicker" then
			plr.PlayerGui.ButtonUI.HasAutoClicker.Value=true
			plr.PlayerGui.ButtonUI.Shop.ScrollingFrame.BuyAutoClicker.Visible=false
			plr.PlayerGui.ButtonUI.Shop.ScrollingFrame.AutoClicker.Visible=true
		end
	end
end)

So if anyone could help me, I would be really glad
Because if i try Eternity.Short(1e400), It will just display E(inf)1, Because anything higher than 1.78e308 will automatically because inf for roblox, And then the .Short function will render it as Eternity.Short(“inf”), But if i try Eternity.Short(“1e400”), It will display the suffix 10DTgCe, So all the number stuff has to get converted to a string. And tostring() will not work as it is much more work than that, and 1.79e308 will automatically make the string inf aswell, which will not work.

2 Likes

You need to create your numbers by adding other EternityNums together.

1 Like

so… like Eternity.Add or something?

1 Like

If its anything like arbitrary precision numbers in other languages then yes. However, you can only add numbers of comparable size otherwise it will just round back down to the same number it was before. That depends on the actual number of bits in the number, which I have no idea about.

1 Like

Well, Could you just make my code work with EternityNum, As i would be very glad with that.

1 Like

No lol

This text will be blurred

1 Like

Not sure if you’re really dedicated to EternityNum or not, but you could also try out InfiniteMath self plug

InfiniteMath has the same limit as EternityNum, and uses metamethods so instead of needing to use functions like Eternity.Add, you can still use the + sign. It also has suffix functions so you don’t need to create your own.

Can it work with normal numbers or does it need strings

1 Like

Any module like this won’t work with numbers, the whole point of the module is its not supposed to work with normal numbers.

You can use numbers up to 1e+308, strings like “1e+400”, or a table like {1, 400}

Well can you at least fix my code so it works with strings or tables instead of numbers? and to make it eternitynum compatible (i like eternitynums suffixes more)

1 Like