dealing with nan values

   9484   5   1
User Avatar
Member
31 posts
Joined: 7月 2005
Offline
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
User Avatar
Member
7899 posts
Joined: 7月 2005
Offline
try:

if foo!=foo then
foo=0
User Avatar
Member
321 posts
Joined: 7月 2005
Offline
edward
try:

if foo!=foo then
foo=0
Wow, 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!
Antoine Durr
Floq FX
antoine@floqfx.com
_________________
User Avatar
スタッフ
2641 posts
Joined: 7月 2005
Offline
Antoine Durr
edward
try:

if foo!=foo then
foo=0
Wow, 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!

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).
User Avatar
Member
21 posts
Joined: 11月 2017
Offline
I had a similar issue.
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
User Avatar
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]
  • Quick Links