Number dividing issue

While dividing, the output is incorrect?

print(1e23 / 1e21)

output:

99.9999999999

It should be 100?

print(math.floor(1e23 / 1e21))

Math.floor returns the closest integer to the given number. (99.9999999999 = 100)

math.floor rounds down meaning 99.99999 would return 99?

Math.rad(), apologies.

charrrrrrrrrrrrrrrrrrrrrrrrrrr

You’re talking about math.ceil or math.round but neither would be useful in my case

Solved it. Apparently in studio dividing numbers doesn’t work properly. So I had to test it in game.

1 Like

Maybe try

local number = 1e23 / 1e21
print(math.ceil(number))

Also why is this needed? Just wondering.

Edit: while typing OP solved it

It’s for my number abbreviation system.

Welcome to the world of floating-point precision errors. This isn’t an issue with studio, this is a caveat of computer science with how decimals are represented and operated on in binary. It’s technically not an error since this behaviour is expected with the nature of how the math works, so you have to work around this kind of stuff.

It is actually a studio issue, I tested it inside of the game and it printed 100, and in studio it was 99.99999999

And I’m guessing the studio issue may be caused by a floating point error. There’s no other explanation I know of at least.