I've been trying to store NaN (not a number) in a variable but it sets it to 0 instead. Right now I have a workaround but it's slow. Is there something else I can do?
My project is at Snap! Build Your Own Blocks (sorry in advance)
Edit: Using a list of length 1 does not work
first of all, you need to reify the variable every time you see [scratchblocks](call (aaaaa) @addInput :: control) [/scratchblocks] in the because calling a number (e.g.
) does not make sense.
Also,
Why do you want to store NaN in a variable? There may be a better way to do what you're trying to do with NaN.
Why are you guys making this so complicated?
![Untitled script pic (4)](https://cdn.forum.snap.berkeley.edu/original/3X/4/0/40e96ae22ecd7d92dc79d9dc6190bd1e8fca63b0.png)
It works at first glance, however it's actually set to 0. The variable watcher still displays NaN, but the block of the variable itself reports 0.
why cant you just set the variable to "NaN"
Technically it's not. NaN is a special type of value, not a string.
![1000405982](https://cdn.forum.snap.berkeley.edu/original/3X/f/4/f419dd0dbcfc2d568b27abfc25544063114e6001.png)
Yup, so there's absolutely no reason to ever store NaN in a variable, because you cannot do anything with it.
Heck, even if you set it to a variable, you can't compare it to itself.
there should never be a reason
NaN is useless unless you wanna make a math library which contains every special value
Maybe for stuff Bignums can't do? IDK.
i am sorry for being wrong. this is very possible
![My Blocks script pic (4)](https://cdn.forum.snap.berkeley.edu/original/3X/5/6/560649b74e6b780d03f1fd062db9cdbca598d825.png)
idk, probably catching bugs (like when a math equation goes wrong)
but now we can exploit this. NaN is the only value that is not = to itself