expression q: rasterize float to n number of fract digits
5458
5
2
bollili
Member
214 posts
Joined: Dec. 2009
Offline
July 28, 2013 7:13 a.m.
Hi,
I don't know if I'm overseeing something very obvious here - sorry, if that would be the case…
How can I “rasterize” a float to have only a given number of fractional digits?
What I mean is an expression like (desired result is 9.12):
xx(2, 9.123456)
Is there something already available? Or do I have to build a function myself?
Thanks,
Marc
hanton
Member
36 posts
Joined: Oct. 2011
Offline
July 28, 2013 11:58 p.m.
unfortunately, no… it seems python also don't have such a built-in function. my solution is floor(9.123456*(10**2))/(10**2), i hope someone can offer a better solution
protozoan
Member
1835 posts
Joined: March 2009
Offline
July 29, 2013 6:39 a.m.
There is nothing better, even though most people do it with “trunc” trunc(315.34543435*100)/100 (but that's basically the same thing)
Martin Winkler
bollili
Member
214 posts
Joined: Dec. 2009
Offline
July 29, 2013 12:05 p.m.
Thanks for your input. That will do it for now… Do you know any resources about how I can add new functions to houdini's scripting language, permanently and/or for the current hip-file only? I always wanted to extend it a little, but don't know where to start. Cheers
animatrix_
Member
5100 posts
Joined: Feb. 2012
Offline
bollili
Member
214 posts
Joined: Dec. 2009
Offline
July 30, 2013 5:02 a.m.
Thanks!