InfiniteMath | Go above 10^308/1e+308!

	upgrade.Price.Text = Price:GetSuffix(true)

Infinite.new(tableValue or value):GetSuffix(true)

EDIT: Alr InfiniteMath.new({Price.first, Price.second}):GetSuffix(true) helped. But for some reason

upgrade.Level.Text = InfiniteMath.new(CurrentLevel.first, CurrentLevel.second).."/"..InfiniteMath.new(Cap.first, Cap.second)				

acting weird too bruh, print
image


error
Ik roblox sometimes think what 0 is nil, but how to fix it bruh(i need this 0, so no i won’t remove it)

Infinite.new is alwqys return metatable you cant always combine it with string u have convert it again with GetSuffix or make it to notation

This is currently true, but in the next update I’ve added the __concat metamethod.

You still might want to use GetSuffix or ScientificNotation or whatever notation you prefer for customization, but if you like the default GetSuffix you can instead just use ...

print(InfiniteMath.new({1, 100000000}).." is huuge") -- 1e+100M is huuge

Next update will introduce Wally support, as well as some better docs!

1 Like

Looks really nice, I can see this be beneficial with crypto implementations for algorithms such as RSA. As of now, I’m used to RoStrap’s BigNum in their Math Library, how does this compare to that (especially in terms of performance)?

1 Like

I’ve never used RoStraps BigNum, but from my experience with BigNum, InfiniteMath is much more performant. This is because BigNum tries to be more accurate, while InfiniteMath sticks with the 15 digits of precision of a float.

Looking at RoStraps BigNum, it seems like InfiniteMath also has many more math functions such as floor, clamp, log, etc. I don’t believe BigNum is compatible with the built in math library (neither is InfiniteMath) so custom functions are needed.

1 Like

RoStrap’s BigNum is a totally different library from BigNum for lua. RoStrap is a project specifically dedicated to rewriting Roblox’s libraries in a more performant manner!

InfiniteMath seems really cool. Will definitely have to try this out sometime soon! Bravo :^)

2 Likes

1.3.0 is here! This is a major update that improves API documentation, functions, and adds Wally support.

You can now visit the documentation website to learn about the module in a much neater way than the readme from before.

  • Removes GetZeros, as Number.second is the same thing.
  • Removes a leftover debug print in clamp
  • Introduces Wally support. (If Wally doesn’t update from 1.2.3, let me know.)
  • Changes DECIMALPOINTS to be a property of InfiniteMath instead of a local variable in the module. This is for Wally support where automatic package updating would reset the variable to default.
  • Improves API and documentation with a new site for InfiniteMath.
  • Adds the __concat metamethod. This uses __tostring, which means printing and concatenating will give the same result.
  • Fixes an issue where when giving a table {first, second} to some functions, an error would occur.
  • Fixes an issue where powers couldn’t support decimals. Powers are also much more performant. This also fixes an issue where powers were returning incorrect results with negative powers, as well as an issue with sqrt where giving constructed numbers would return the same number instead of the square rooted number.
  • Fixes an issue with log not supporting numbers over 10^308.

Get just the module here: InfiniteMath - Roblox

2 Likes

Hey, late answer, yeah ik that. Btw i reworked a bit everything by making fixer function in all scripts(it just converts value to metatable back)
image
for some reason this happens only with one thing

here is where print located
image

also i tryed printing type of value
and value.first is string and value.second is number :confused: . When to ds it is saved as InfiniteMath.new(10)

I made kinda dumb solution just using tonumber(num.first) and tonumber(num.second), idk if it is good

1 Like

Don’t save it to the datastore as a metatable. Instead, save first and second in a table.

local Money = InfiniteMath.new(100)

Data.Money = {Money.first, Money.second}

Then reconstruct it when you access it from the data. You can use tables now as an input to new, so just give it the table you created.

local Money = InfiniteMath.new(Data.Money)

Using tonumber is fine, but it shouldn’t be getting saved as a string in the first place. It could be because you’re trying to save the entire metatable which is bad practice, or something else in your code.

1 Like

Ah alr thank you. Another(i think finally last question). Is it possible to use decimal points only for number i need? Like this looks kinda
image
strange ig(this is upgrade level)? Or should i change InfiniteMath decimalpoint variable to 0 right before this?

1 Like

Try using InfiniteMath.round, it should remove the extra 0’s at the end. Also make sure your module is up to date, its not automatic.

1 Like

Yeah that would work, but i think it would be useful for functions like suffix and notations should have decimalPoints arg(like i sometimes need to use other amount of decimalpoints on some moment) and if decimalPoints arg is nil then just take default value from InfiniteMath. This is just a little suggestion i think(it is kinda useful) (I’m sorry if this bad suggestion, but i would be grateful to see it there). That’s how i done it with suffix function(just 3 new lines lol)

function Number:GetSuffix(abbreviation, dPoints)
...
if dPoints == nil then
		dPoints = InfiniteMath.DECIMALPOINTS
	end
...
if dPoints > 0 then
result = result:sub(1, second + 2 + dPoints)
...

This kinda helpful ig(atleast for me). Sorry if i took ur time there xd

EDIT: Btw module is up to date, i took it again today(maybe i don’t get and there is something like i said alr, but i can’t see it(don’t kill me pls) )

1 Like

Yeah I could see something like that being useful, I’ll consider it.

If you got the module today then you’re up to date, just making sure.

2 Likes

Alright. Thank you for answer anyways :slight_smile:

2 Likes

1.3.1 is here, its a very small update that fixes Wally and removes some unused code.

  • Removed an unused function & silenced LocalUnuseds
  • Fixed default.project for Wally

Get just the module here: InfiniteMath - Roblox

2 Likes

I made something similar to this but with further mathematical operations, based on the BigInt library from Luarocks.

1 Like

Seems like BigInt is more about increasing the limit with the precision of an Integer, with a limit of 2^2^53, while InfiniteMath is focused on increasing the limit with precision of Floats which lets us have a much higher limit of 10^^308 (^^ = tetration).

Just depends whether you value accuracy or a higher limit more, very interesting though.

1 Like