I posted a similar post on odforce, so I apologize if you are reading this twice.
I have a vex operator that's reading an i3d file, some of the values being returned are nan
values. I was wondering if there's a way to test for nan values and replace them
with something different
eg
if foo==nan then
foo=0
thanks
Luca
dealing with nan values
9530 5 1- lucap
- Member
- 31 posts
- Joined: July 2005
- Offline
- edward
- Member
- 7902 posts
- Joined: July 2005
- Offline
- Antoine Durr
- Member
- 321 posts
- Joined: July 2005
- Offline
- mark
- Staff
- 2642 posts
- Joined: July 2005
- Online
Antoine DurredwardWow, does this really work? I was under the impression that once you have a NaN in your calculation, pretty much everything that got near it would break. Good to know!
try:
if foo!=foo then
foo=0
According to IEEE spec on floating point, every comparison with a NAN is false.
I'm not 100% sure this filters down to expressions though (or Python for that matter).
- wmpcg
- Member
- 21 posts
- Joined: Nov. 2017
- Offline
I had a similar issue.
Try something like:
Just found this post:
vex isnan [forums.odforce.net]
Try something like:
if(sprintf("%g",yourVar) == "-nan(ind)") { @group_delete = 1; }
Just found this post:
vex isnan [forums.odforce.net]
Edited by wmpcg - Sept. 19, 2019 12:22:34
- alexwheezy
- Member
- 318 posts
- Joined: Jan. 2013
- Offline
You can check using this function for example,
https://www.sidefx.com/docs/houdini/vex/functions/isnan.html [www.sidefx.com]
https://www.sidefx.com/docs/houdini/vex/functions/isnan.html [www.sidefx.com]
-
- Quick Links