Jump to content

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?

truncate_float_in_font.hiplc

truncate_float_in_font.PNG

Link to comment
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.

Link to comment
Share on other sites

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...