Floor behaving weirdly

Floor behaving weirdly

sandbergGJZSN
Enthusiast Enthusiast
1,095 Views
3 Replies
Message 1 of 4

Floor behaving weirdly

sandbergGJZSN
Enthusiast
Enthusiast

Just found out that this maxscript:

 

floor(100.0 * 1.05)

 

Gives the result:

104.0

 

I'm just curious if i misunderstand something, but i thought it would return 105.0.

Anyone know why it behaves like this?

0 Likes
Accepted solutions (1)
1,096 Views
3 Replies
Replies (3)
Message 2 of 4

istan
Advisor
Advisor
Accepted solution

https://help.autodesk.com/view/MAXDEV/2021/ENU/?guid=GUID-B57EA575-DCDE-42F5-9D30-88E3EB41F350 

math is internally in float.. so of course there is some sort of inaccuracy in every calculation.. even with double calc, the result 105.0 will not be exact.. see: https://en.wikipedia.org/wiki/IEEE_754 

 

Message 3 of 4

sandbergGJZSN
Enthusiast
Enthusiast

Thanks for the reply!

 

I won't trust printed floats ever again xP

0 Likes
Message 4 of 4

istan
Advisor
Advisor

@sandbergGJZSN wrote:

Thanks for the reply!

 

I won't trust printed floats ever again xP


therefore we developers invented the integer values 😁

0 Likes