If you have ever felt that 1.79e308 just isn’t a large enough upper limit for numbers in your game, then this tutorial is for you!
EternityNum2 is a module created by FoundForces that can calculate values up to with the power of strings, and I am going to teach you how to start using it.
Setting it up :
-
Download the model here, and place it in ReplicatedStorage.
-
Now, create a script anywhere. I will be placing a
LocalScript
underStarterPlayerScripts
. Require the module, and you can now start working!
How to work with it :
If you have ever used BigInteger in Java, or even written excel formulas, the logic is very similar in EternityNum. While we usually write 10 + 3 * 2
, in EternityNum we will write add(10, mul(3, 2))
The innermost operations are calculated first.
A list of all EternityNum operations can be found at the top of the module.
So let’s try solving 10 * ((9 / 2) ^ 100)
- Start with the innermost operation and work outwards, 9 / 2:
div(9, 2)
- The next innermost operation is x ^ 100:
pow(div(9, 2), 100)
- The only operation left is 10 * x:
mul(10, pow(div(9, 2), 100))
In EternityNum, this looks like:
I added the original equation so that we can compare answers. Let’s try running this and see if our code is right!
Woah, whats with this table ? Explanation: This is just how EternityNum stores numbers! Here is what it means: Sign: Indicates whether the number is positive (1), negative (-1), or zero (0). Layer: Determines the logarithmic layer. If it is 1, we use log10(x); if 2, we use log10(log10(x)), and so on. Exp: The result of the logarithmic operation. For example, given the table [66.3, 1, 1]: The sign value (1) means the number is positive. The layer value (1) indicates we are using log10(x) The exp value (66.3) represents log10(x) = 66.3. To find the real value, solve 1066.3
Lets convert this table into a nicer format for our eyes. Wrap the equation in etNum.toScientific()
, this converts the table into scientific notation.
Perfect!
Application of it :
Now, I want you to script a use case for this. We have not nearly hit the numerical limits yet!
Create a ScreenGui
with a TextButton
under it, and under this TextButton, make a new StringValue
, and set it’s value to 1. This will hold the value of the button.
When the button is clicked, I want you to multiply its value by 1000, and display the new value in the button. Tip: to store an EternityNum value in a string value, you will need to use the function toString()
I would also recommend using the function short()
to turn the value into a nice suffixed format.
Solution:
local etNum = require(game.ReplicatedStorage.Modules.EternityNum)
local playerGui = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui")
local textButton = playerGui:WaitForChild("TextButton")
local function multiplyNumberBy1000(number)
return etNum.mul(number, 1000)
end
textButton.MouseButton1Click:Connect(function()
textButton.Value.Value = etNum.toString(multiplyNumberBy1000(textButton.Value.Value))
textButton.Text = etNum.short(textButton.Value.Value)
end)
If you have made it here, great job, and thank you for reading! You now know enough to figure out every other facet of EternityNum on your own. But continue reading the next section if you would like!
Additional stuff :
- To store an EternityNum value in datastore, I recommend using
toString()
- You can display your numbers in several different formats, I prefer
toScientific()
andshort()
- To compare EternityNum values, use
me(x, y) (x > y)
meeq(x, y) (x >= y)
le(x, y) (x < y)
leeq(x, y) (x <= y)
eq(x, y) (x == y)
between(val, x, y) (x < val < y)
- Most functions are versatile in their accepted inputs. They will accept EternityNum tables, regular numbers, and numbers as strings (
"10"
,"1e3",
"1e-4"
,"1;54.3"
).
If you have any questions, feel free to reply. This is my first tutorial, and I hope it will help some of you who were as confused as I was when I first tried using this module.