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

Can you send me a link to EternityNum 2? I can take a look at the source code and maybe improve performance.

1 Like

its available on toolbox just search EternityNum also its not available on github

2 Likes

I looked into it and realized I don’t need to be storing numbers as strings, I can just store the 2 numbers separately.

With this change, doing about 100000 calculations per second went from using around 15% activity to about 6%.

There’s still a few things I need to work on so it’s not ready yet, but so far it should require minimal work on your end to use the new update.

Shouldn’t NaN compare false with anything, even itself?

1 Like

That’s true, nan == nan is false, but currently the module treats nan == nan as true.

I’ll update it so that nan is treated differently. If you want to check if a number is nan, instead check if number ~= number.

1.2.0 has been released!

This update requires changes to be made to your implementation.

Num.val no longer exists, there is now Num.first and Num.second. Anything that uses val must be updated to use first and second, mainly in datastores.

Instead of storing val, store a table with first and second, {first, second}

  • Major performance improvements by storing InfMath numbers as 2 numbers instead of a string.
  • Prevented numbers with a negative amount of zeros from being created.
  • Fixed an issue with clamp not correctly working with negative numbers.
  • Fixed an issue with < and <= not correctly working with negative numbers.
  • Made nan work correctly with ==.
  • You can now create numbers with a table {1, 0}

Get just the module here: InfiniteMath - Roblox

2 Likes

could u compare this with EternityNum2?

New update! This is a smaller update that fixes a few issues.

  • Fixes an issue with when the result of division is below 1. For example, 5/10 would return 5 instead of 0.5. This was due to an old fix I had for second going below 0 that was interfering with a newer fix. Now, 5/10 will return 0.5.

  • Improves floor and round, performance should be improved (micro-optimization) and results below 1000 should be more accurate.

  • Fixes ceil. At certain milestones ceil would return numbers larger than usual. For example, 988.1 would return 989, but 989.1 would return 9.1K. Performance should also be better (micro-optimization) and results should be more accurate below 1000.

Get just the module here: InfiniteMath - Roblox

1 Like

1.2.2 is here! This update fixes an issue and adds a new variable.

  • Fixed an issue with round where it would always use ceil instead of using ceil or floor based on if the decimal is above or below .5

  • Fixed an issue with GetSuffix where numbers below 1000 would be returned with a .9 or .1 at the end sometimes. This is fixed by just returning the result of Reverse if the number has less than 3 zeros.

  • Added a DECIMALPOINTS variable in the module to control how many decimals a number can display. The default has been changed from 1 to 2.

Get just the module here: InfiniteMath - Roblox

Very small 1.2.3 update to fix something introduced in yesterdays 1.2.2.

  • Fixed GetSuffix ignoring DECIMALPOINT when returning numbers below 1000. This would create numbers with very long amounts of decimals, for example 1.242128098321, instead of shortening to 1.24.

  • Changed the leaderboard decimal point precision variable name from DECIMALPOINT to LEADERBOARDPOINT now that we have the DECIMALPOINTS variable.

Get just the module here: InfiniteMath - Roblox

Hey. I have a question(if you are even answering them though). I’m using InfiniteMath module for a few days and it seems to break metatable when saving to normal datastore(not ordered one). Lua just converts it to default table ig? I can’t use any function on that table and starting to get comparing errors like that.


Maybe i should save value by some different method(not saving it as metatable to ds? Just like you don’t have any explanation on how it works with normal datastore and how properly save InfiniteMath value to it) I tryed looking though demonstration game save code, but for me it was kinda messy, so i didn’t understand how you saving them

For saving it in a datastore, you need to save the values of the number and then reconstruct it when you use it.

Datastores don’t like metatables so I don’t think there’s a way to get around this besides creating a function on the number to convert it for datastore use, but its really easy to do it yourself.

If you have InfiniteMath.new(100), the values are {1, 2}. To get that you use first and second. Then when you want to access numbers from the datastore you reconstruct it.

--saving to datastore

local Number = InfiniteMath.new(100)
Data.Money = {Number.first, Number.second}

--access from data table

local Money = InfiniteMath.new(Data.Money[1], Data.Money[2])

All you need is the two numbers first and second, the method you store them doesn’t matter. Could be in NumberValues, it could be a string or a table, just as long as you can get the 2 numbers separate to reconstruct.

Ah i see what you mean. What about saving value as string(1e23 for example) and then fix it back to {1, 23}?

You could do that, but its more work for something that’ll get the same thing done.

You have a point. Though it still works weird idk.(I’m currently wrapped my table of empty player data in InfiniteMath(i’m not adding new data while player is playing, i’m using template table of player data)

print(sessionData[player.UserId]["Upgrades"][Type][upgradeName][parameter].first)
	print(sessionData[player.UserId]["Upgrades"][Type][upgradeName][parameter].second)
	local val = InfiniteMath.new(sessionData[player.UserId]["Upgrades"][Type][upgradeName][parameter].first,sessionData[player.UserId]["Upgrades"][Type][upgradeName][parameter].second)
print(val)

this part of code prints:

print(sessionData[player.UserId]["Upgrades"][Type][upgradeName][parameter].first)
1

print(sessionData[player.UserId]["Upgrades"][Type][upgradeName][parameter].second)
1

--but after converting to infinite math it says
print(val)	
0

I’m converting it like that

 InfiniteMath.new(sessionData[player.UserId]["Upgrades"][Type][upgradeName][parameter].first,sessionData[player.UserId]["Upgrades"][Type][upgradeName][parameter].second)

that’s really strange, also infinite math says me that

ReplicatedStorage.InfiniteMath:16: invalid argument #1 to 'round' (number expected, got nil) 

Also saving looks like that

Cap = InfiniteMath.new(10)

Weird thing(no point why it’s not converting properly)

try this

InfiniteMath.new({sessionData[player.UserId]["Upgrades"][Type][upgradeName][parameter].first,sessionData[player.UserId]["Upgrades"][Type][upgradeName][parameter].second})

.new return metatable with 2 values when print it out, but to reconvert it bacm u have to made into table

Setup on GitHub w/ Wally and you’ll be a godsend :pray:

Yeah i already found this by myself. But for some reason metatable breaks again after travelling though remote event(idk why)

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

this line outputs error(Price is already fixed value)
So happens this

dont Infinite.round with table value