Jump to content
Sign in to follow this  

float parameter is -0.7, font displays -0.6999999999999996

Recommended Posts

I attach file where I use font to display parameters.

Both are float, but one shows as the exact number I've entered, and the other is misbehaving. For scattering phase I've entered -0.7 but it's displaying -0.69999999999999996 This is not helping visualise the parameters used. I just need my -0.7

Other than wondering why one float is ok and the other is not, how do I get the font to read and display -0.7 correctly?



Share this post

Link to post
Share on other sites

Well it all depends on what you want to call "correct".

Houdini, like a lot of computer programs, uses floating point numbers to represent its number system. It's a bit complicated, but think of it like scientific notation in binary. The short answer is that in floating point 0.7 has an endlessly repeating decimal, kind of like how if you tried to write 1/3 in standard notation, you'd end up with endless .3333333333333s. Same thing. So instead Houdini picks the closest value it can simply represent in floating point. In this case, it's 0.69999999999999996. If you click on the parameter name, it will expand to show you the actual floating point value that Houdini is using internally for its calculations. If you click the parameter again, it collapses down to a simplified value that Houdini chooses to display.

So what you are seeing is "correct". It is displaying the actual value that Houdini is using to calculate the scattering phase. But it's also annoying to look at so many decimals. So depending on what you want: in your expression use something like round() or floor() or ceiling() to truncate the value to something easier to read.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this