Infinite Number Library

Hello!
I have made a cool module script around a month ago, and I wanted to share it with the public.

Its essentially my attempt at creating the BigNum library.
It is a little bit faster than BigNum library but its less precise.
It uses string modification instead of just normal math.

Usage:

Mine has nothing fancy like bignum, it is just a module script with functions in it.
To use it, just require it from anywhere where its located and you’re good to go.

local InfNum = require(LOCATION)

Information:
This module works by turning the given numbers into E notation that doesn’t use the letter e or E because roblox automatically turns a number higher than the limit into inf if it uses this format:
%d+%.?%d*[eE][+-]%d+.
Therefore I used the letter “d” instead of “e” or “E”.
(This can be changed at the top of the module script if you want)

The PRECISION setting determines how many decimals behind the first number will be shown.

And the TIME_LIMIT determines what is the timeout for loops in seconds.
If you calculate with extremely extremely large numbers, your studio would crash.
Therefore you can set the time limit of the loops so if it reaches, lets say: 15 seconds, it will break the loop preventing you from crashing.

Functions

InfNum.Add

  • a: number
  • b: number
  • returns: a + b
  • example: InfNum.Add("1d+500", "3.5d+750") → +4.5d+500

InfNum.Sub

  • a: number
  • b: number
  • returns: a - b
  • example: InfNum.Sub("4.25d+7535", "7.5d+7535") → -3.25d+7535

InfNum.Mul

  • a: number
  • b: number
  • returns: a * b
  • example: InfNum.Mul("1.5d+250", "5d+710") → +7.5d+960

InfNum.Div

  • a: number
  • b: number
  • returns: a / b
  • example: InfNum.Div("1.5d+500", "5d+501") → +3d-02

InfNum.Mod

  • a: number
  • b: number
  • returns: a % b
  • example: InfNum.Mod("5d+1052", "5d+500") → +0d+00

InfNum.Fac

  • n: number
  • returns: n!
  • example: InfNum.Fac("6d+5") → +2.1187975d+3206317

InfNum.Larger

  • a: number
  • b: number
  • returns: a > b
  • example: InfNum.Larger("6d+5", "5d+5") → false

InfNum.Smaller

  • a: number
  • b: number
  • returns: a < b
  • example: InfNum.Smaller("6d+5", "5d+5") → true

InfNum.Equal

  • a: number
  • b: number
  • returns: a == b
  • example: InfNum.Equal("6d+5", "5d+5") → false

InfNum.pow

  • a: number
  • b: number
  • returns: a ^ b
  • example: InfNum.pow("2.5d+10", "1.1d+5") → +2.517409832530934d+1143773

InfNum.sqrt

  • a: number
  • b: number
  • returns: a ^ b
  • example: InfNum.sqrt("2.5d+5") → +5.00277d+02

InfNum.round

  • n: number
  • returns: math.round(n)
  • example: InfNum.round("1.5d+0") → +2d+00

InfNum.floor

  • n: number
  • returns: math.floor(n)
  • example: InfNum.floor("1.5d+0") → +1d+00

InfNum.ceil

  • n: number
  • returns: math.ceil(n)
  • example: InfNum.ceil("1.5d+0") → +2d+00

InfNum.tonumber

  • n: number
  • returns: "1.5d+5" -> 150000
  • example: InfNum.tonumber("1.5d+5")

I don’t think this will be useful for anything, but it was very fun to make.
Get Module

5 Likes
2 Likes

ye, I know. This is just my attempt at creating it, I’m not claiming that I have invented something new. This is all old stuff at this point, but I still had a lot of fun making it.