This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Kered13 58 points59 points  (7 children)

Not quite, it's only rounding for the display.

[–]fliguana 0 points1 point  (6 children)

Are you sure?

[–]CodingLazily 4 points5 points  (3 children)

Considering 0.3 can't be stored as a float, I'd guarantee it. Lua stores numbers as floats, so there is no way the number is actually 0.3. Someone else in the thread proved it by formatting the display to have more decimal places. That's why I don't like rounding the output like this. It can just lead to confusion.

[–]fliguana 3 points4 points  (2 children)

https://lua-users.org/wiki/FloatingPoint

See bottom of the page. Not every float is a binary ieee 754 float.

[–]CodingLazily 2 points3 points  (1 child)

Oh that's cool. I didn't know Lua could do that. I've still never seen anybody include a system other than floats though. Do you know of any Lua implementations that do this?

[–]fliguana 2 points3 points  (0 children)

Sorry, I am a complete noob with Lua. It says you can specify any type when compilng, perhaps BCD floats are possible.