anicg Posted August 3, 2022 Share Posted August 3, 2022 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 Quote Link to comment Share on other sites More sharing options...
madebygeoff Posted August 6, 2022 Share Posted August 6, 2022 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. Quote Link to comment Share on other sites More sharing options...
jkunz07 Posted August 26, 2022 Share Posted August 26, 2022 You can use the ftrim expression in the font sop like this `ftrim(ch("../../../mat/materialbuilder1/volumeshadercore1/phase"))` or see the attached file ftrim_float_in_font.hiplc Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.