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
9484 5 1- lucap
- Member
- 31 posts
- Joined: 7月 2005
- Offline
- edward
- Member
- 7899 posts
- Joined: 7月 2005
- Offline
- Antoine Durr
- Member
- 321 posts
- Joined: 7月 2005
- Offline
- mark
- スタッフ
- 2641 posts
- Joined: 7月 2005
- Offline
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: 11月 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 - 2019年9月19日 12:22:34
- alexwheezy
- Member
- 318 posts
- Joined: 1月 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