AdvancedDouble - An advanced number library capable of exceeding 10 ^ 308

This library is currently in early alpha, lots of bugs and glitches may occur! Report all bugs if you can!

What is AdvancedDouble?
AdvancedDouble is a Roblox Math Library created for developers who want to calculate numbers as high as 10^-10^-308, and as low as 10^- - 10^-308

Features
Operator overloading, allowing the use of operators such as +, *, ^, /
Custom formats, stored in AdvancedDouble/Formats/
You can make your own format using the instructions listed later in the module!

Functions as of the current version
Log(Number, Base) – Works like math.log
Log10(Number) – Basically returns Log(Number, 10)
Add(Number, Number2) – Add two numbers together
Multiply(Number, Number2) – Multiply two numbers together
Power(Number, Number2) – Power two numbers together
Format(Number, Notation: string) – Format a number into a specified suffix, like 10DTg*

Does this library support Lua operators, such as +, “*”, ^, / etc?
Yes, this library uses metatables and metamethods to allow support for operator overloading!

What is this library intended for?
This module is intended for idle/incremental games or games that are known to exceed extremely large numbers

That’s cool and all, but how do I use it?
Get the module here — AdvancedDouble
Now you can import it from the toolbox by going to Toolbox → Inventory → My Models and select the AdvancedDouble

For now, place it into ReplicatedStorage

How to setup after importing
Create a new script anywhere in your experience, and try some of the following code

local AdvancedDouble = require(game:GetService("ReplicatedStorage").AdvancedDouble)

--[[
 We can create AdvancedDouble numbers using either:
 Strings: AdvancedDouble("1.00e500") - returns {1, 500}
 Number: AdvancedDouble(10^100) returns {1, 100}
 Using 2 numbers: AdvancedDouble(1, 250) returns {1, 250}
 
 It also works on very small numbers
 AdvancedDouble(8.999, -1672) -- returns 0.000000000000 ... 0000089 with 1671 zeros
]]

-- Create a new AdvancedDouble number
local FirstNumber = AdvancedDouble(1, 0)

-- Firstly, lets add FirstNumber by 1
FirstNumber = FirstNumber + AdvancedDouble(1, 0) -- Using metamethods, we can use Lua operators on AdvancedDouble numbers!

print(FirstNumber) -- By default this should return 2e0

-- We can use AdvancedDouble.Format() to format our number into something better
print(AdvancedDouble.Format(FirstNumber, "Standard")) -- Use our bundled standard notation

-- The library can also use operators such as >=, <=, >, <, == etc
print(FirstNumber >= AdvancedDouble(1, 1)) -- returns false, because 1 is not more than 10
6 Likes

this vs Infinite Math or EternityNum2?

Is there data loss with small numbers adding into large numbers?

It really depends on the difference of the amount of zeros between the two numbers, if you really want to add small numbers into big ones, change the MaxSignificantDigits setting in AdvancedDouble → Settings

By default it is 17, so if you add 1.00e30 to something like 1.00e48, It will not be affected because it is too small and would not make any noticeable difference when formatting

It’s so interesting to see other people come up with solutions to problems I’ve had to fix over the last 3 years with these kinds of systems. Good job!