My textlabel not showing bigger number that 1e310

From what i read roblox dont allow to show number bigger that 1e310 and it show it as inf.
But i have been seen a games that have bigger numbers that 1e310 i try doing some calculations and etc but still show inf.

Is there a possible way to make it show the real number unsted of inf ?

The currect script that i use for the prefixes.

local Short = {}

Short.Comma = function(Value)
	local Number
	local Formatted = Value
	while true do  
		Formatted, Number = string.gsub(Formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
		if (Number == 0) then
			break
		end
	end
	return Formatted
end

function addComas(str)
	return #str % 3 == 0 and str:reverse():gsub("(%d%d%d)", "%1,"):reverse():sub(2) or str:reverse():gsub("(%d%d%d)", "%1,"):reverse()
end

local function roundWhole(n)
	return math.floor(n + 0.5)
end

local function roundDecimal(t)
	return math.floor(t * 10) * 0.1
end

Short.en = function(Input)
	local prefixes = {
		"K", "M", "B", "T", 
		"aa", "ab", "ac", "ad", "ae", "af", "ag", "ah", "ai", "aj", "ak", "al", "am", "an", "ao", "ap", "aq", "ar", "as", "at", "au", "av", "aw", "ax", "ay", "az",
		"ba", "bb", "bc", "bd", "be", "bf", "bg", "bh", "bi", "bj", "bk", "bl", "bm", "bn", "bo", "bp", "bq", "br", "bs", "bt", "bu", "bv", "bw", "bx", "by", "bz",
		"ca", "cb", "cc", "cd", "ce", "cf", "cg", "ch", "ci", "cj", "ck", "cl", "cm", "cn", "co", "cp", "cq", "cr", "cs", "ct", "cu", "cv", "cw", "cx", "cy", "cz",
		"da", "db", "dc", "dd", "de", "df", "dg", "dh", "di", "dj", "dk", "dl", "dm", "dn", "do", "dp", "dq", "dr", "ds", "dt", "du", "dv", "dw", "dx", "dy", "dz"}

	if Input < 1000 then
		return string.format("%d", Input)
	end

	local index = 0
	while Input >= 1000 and index < #prefixes do
		Input = Input / 1000
		index = index + 1
	end

	local formattedValue
	if Input == math.floor(Input) then
		formattedValue = string.format("%.0f", Input)
	elseif Input >= 100 then
		formattedValue = string.format("%.0f", Input)
	elseif Input >= 10 then
		formattedValue = string.format("%.1f", Input)
	else
		formattedValue = string.format("%.2f", Input)
	end

	formattedValue = formattedValue:gsub("%.0$", "")

	formattedValue = formattedValue:gsub("%.", ",")

	return formattedValue .. prefixes[index]
end

return Short

screen to show the textlabel
image

Really? I haven’t seen one. (or probably grinded long enough)

Anyways, in this case, you need to find a new way to process and store the numbers (maybe scientific notation).

I recommend using a module that handles this for you, like InfiniteMath.

As for showing the ‘real number’, it will depend on the module you are using and you’ll have to figure out how you want to output, I think InfiniteMath has a feature for this:

If your game’s numbers go bigger than 1e+12000, maybe you could change the prefixes table (the correct word here is suffix, prefix is put before the number) into a dictionary that maps each prefix suffix with the corresponding scientific notation of the smallest number it should be used with. (for eg. “K” = 1e3)

Then, whenever you wanna update the textlabel, you get the ScientificNotation() and the first few digits of the number which is stored in InfiniteMath, add the suffix which you got from the dictionary at the end and slap that string onto the textlabel.

(Or literally just use GetSuffix() if your game doesn’t go past 12000 digits)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.