Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

NumberValue going down by something like 0.0000000001?

Lets say I use this code: p.leaderstats.Money.Value = 200.1 it should set the players money to 200.1, correct? Now the leaderboard will indeed say 200.1, however if the money has something subtracted from it, or if I go into the player, and check the value myself, it will equal 200.09999999999999. Does anyone know why? The leaderboard code does not do anything to the value of it.

1 answer

✓ Accepted answer

Floating-point errors. In exchange for a larger range of numbers, computers sacrifice the ability to represent a large amount of numbers exactly (especially decimals). This can have issues when checking for equality, but this can be resolved by factoring in a very small number, often called Epsilon.

ROBLOX uses doubles, so can represent integer numbers exactly up to something like +/- 1000000000000000 (according to a simple test that I ran)

https://en.wikipedia.org/wiki/Floating_point https://en.wikipedia.org/wiki/Machine_epsilon

2 comments

0

So is there a way for me to actually make it 200.1, as adding something to it is very odd.

0

There is no way. 200.1 cannot be represented in floating-point format. It will probably not affect you, anyway.

This discussion is preserved as it was. New answers, comments, and votes are closed.