Skip to main content

Number

An InfiniteMath constructed number that has a limit of -10^^308 to 10^^308.

Functions

SetValue

Number:SetValue(
newFirstnumber,
newSecondnumber
) → ()

Sets the value of the constructed number without creating a new Number metatable. If you want to set the value of a constructed number it is better to use this than setting it to a new .new().

SetValue takes a new first and second to set the value to, if you want to set the value to 100 you must pass 1, 3.

	local Number = InfiniteMath.new(1000)
	print(Number) -- 1000
	Number:SetValue(5, 4)
	print(Number) -- 5000

Reverse

Number:Reverse() → number

Attempts to return the constructed number converted into a regular number. If the constructed number is above 1e+308 it will instead return INF.

	print(InfiniteMath.new("1, 3"):Reverse()) -- 1000

GetSuffix

Number:GetSuffix(abbreviationboolean | nil) → string

Returns a string with the number and a suffix at the end, these suffixes will go up to 1e+12000. After, it will default to returning scientific notation.

By default, it will return an abbreviated suffix (1K). Using true will use the default behavior. Using false will return the full suffix (1 Thousand).

	print(InfiniteMath.new(1000):GetSuffix()) -- 1K
	print(InfiniteMath.new(1000):GetSuffix(true)) -- 1K
	print(InfiniteMath.new(1000):GetSuffix(false)) -- 1 Thousand

ScientificNotation

Number:ScientificNotation(
abbreviationboolean | nil,
secondAbbreviationboolean | nil
) → string

Returns a string with the number formatted in scientific notation.

	print(InfiniteMath.new(1000):ScientificNotation()) -- 1e+3

When a number reaches 1e+1000000 you can choose an abbreviation mode for the amount of zeros in the scientific notation. By default, it will use GetSuffix on the exponent 1e+1M, but you can also choose to have it use scientific notation 1e+1e+6.

	print(InfiniteMath.new("1, 1e+6"):ScientificNotation()) -- 1e+1M
	print(InfiniteMath.new("1, 1e+6"):ScientificNotation(true)) -- 1e+1M
	print(InfiniteMath.new("1, 1e+6"):ScientificNotation(false)) -- 1e+1e+6

You can also use nil and false to stop the functionality and instead just display 1e+1000000.

	print(InfiniteMath.new("1, 1e+6"):ScientificNotation(nil, false)) -- 1e+1000000

LogarithmNotation

Number:LogarithmNotation() → string

Returns a string with the number formatted in logarithmic notation.

	print(InfiniteMath.new(1000):ScientificNotation()) -- e3.0

aaNotation

Number:aaNotation() → string

Returns a string with the number formatted in double letter notation. Use the AALENGTHMAX property to adjust the max letters possible.

	print(InfiniteMath.new(1e+15):aaNotation()) -- 1a

ConvertForLeaderboards

Number:ConvertForLeaderboards() → number

Returns a number that you can use for OrderedDataStores in order to create global leaderboards that support InfiniteMath constructed numbers.

	print(InfiniteMath.new(1000):ConvertForLeaderboards()) -- 31000
Show raw api
{
    "functions": [
        {
            "name": "SetValue",
            "desc": "Sets the value of the constructed number without creating a new Number metatable. If you want to set the value of a constructed number it is better to use this than setting it to a new `.new()`.\n\n`SetValue` takes a new `first` and `second` to set the value to, if you want to set the value to `100` you must pass `1, 3`.\n\n```lua\n\tlocal Number = InfiniteMath.new(1000)\n\tprint(Number) -- 1000\n\tNumber:SetValue(5, 4)\n\tprint(Number) -- 5000\n```",
            "params": [
                {
                    "name": "newFirst",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "newSecond",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 435,
                "path": "src/InfiniteMath/init.lua"
            }
        },
        {
            "name": "Reverse",
            "desc": "Attempts to return the constructed number converted into a regular number. If the constructed number is above 1e+308 it will instead return INF.\n\n```lua\n\tprint(InfiniteMath.new(\"1, 3\"):Reverse()) -- 1000\n```",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 459,
                "path": "src/InfiniteMath/init.lua"
            }
        },
        {
            "name": "GetSuffix",
            "desc": "Returns a string with the number and a suffix at the end, these suffixes will go up to 1e+12000. After, it will default to returning scientific notation.\n\nBy default, it will return an abbreviated suffix (1K). Using true will use the default behavior. Using false will return the full suffix (1 Thousand).\n\n```lua\n\tprint(InfiniteMath.new(1000):GetSuffix()) -- 1K\n\tprint(InfiniteMath.new(1000):GetSuffix(true)) -- 1K\n\tprint(InfiniteMath.new(1000):GetSuffix(false)) -- 1 Thousand\n```",
            "params": [
                {
                    "name": "abbreviation",
                    "desc": "",
                    "lua_type": "boolean | nil"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 483,
                "path": "src/InfiniteMath/init.lua"
            }
        },
        {
            "name": "ScientificNotation",
            "desc": "Returns a string with the number formatted in scientific notation.\n\n```lua\n\tprint(InfiniteMath.new(1000):ScientificNotation()) -- 1e+3\n```\n\nWhen a number reaches `1e+1000000` you can choose an abbreviation mode for the amount of zeros in the scientific notation. By default, it will use GetSuffix on the exponent `1e+1M`, but you can also choose to have it use scientific notation `1e+1e+6`.\n\n```lua\n\tprint(InfiniteMath.new(\"1, 1e+6\"):ScientificNotation()) -- 1e+1M\n\tprint(InfiniteMath.new(\"1, 1e+6\"):ScientificNotation(true)) -- 1e+1M\n\tprint(InfiniteMath.new(\"1, 1e+6\"):ScientificNotation(false)) -- 1e+1e+6\n```\n\nYou can also use nil and false to stop the functionality and instead just display `1e+1000000`.\n\n```lua\n\tprint(InfiniteMath.new(\"1, 1e+6\"):ScientificNotation(nil, false)) -- 1e+1000000\n```",
            "params": [
                {
                    "name": "abbreviation",
                    "desc": "",
                    "lua_type": "boolean | nil"
                },
                {
                    "name": "secondAbbreviation",
                    "desc": "",
                    "lua_type": "boolean | nil"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 570,
                "path": "src/InfiniteMath/init.lua"
            }
        },
        {
            "name": "LogarithmNotation",
            "desc": "Returns a string with the number formatted in logarithmic notation.\n\n```lua\n\tprint(InfiniteMath.new(1000):ScientificNotation()) -- e3.0\n```",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 600,
                "path": "src/InfiniteMath/init.lua"
            }
        },
        {
            "name": "aaNotation",
            "desc": "Returns a string with the number formatted in double letter notation. Use the AALENGTHMAX property to adjust the max letters possible. \n\n```lua\n\tprint(InfiniteMath.new(1e+15):aaNotation()) -- 1a\n```",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 638,
                "path": "src/InfiniteMath/init.lua"
            }
        },
        {
            "name": "ConvertForLeaderboards",
            "desc": "Returns a number that you can use for OrderedDataStores in order to create global leaderboards that support InfiniteMath constructed numbers.\n\n```lua\n\tprint(InfiniteMath.new(1000):ConvertForLeaderboards()) -- 31000\n```",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 678,
                "path": "src/InfiniteMath/init.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Number",
    "desc": "An InfiniteMath constructed number that has a limit of -10^^308 to 10^^308.",
    "source": {
        "line": 18,
        "path": "src/InfiniteMath/init.lua"
    }
}