Autonomous Problems / I'm dumb

Ok so I’m trying to get Autonomous up and running and forgot what I would use to convert from Int to Boolean,
if you can even do that.
I’m not even sure anymore.
:yikes: :o

While there are casts, the best (most readable and consistent across languages) way to convert a number to Boolean is to us a comparison operator. For example, if you want false when x is zero and true otherwise, use (x!=0).

Edit: that’s ok with integers. With floats, you have to watch out for NaN cases. My favorite way to test around all of the cases where x is not a number is to do something like (x==x && x!=0).

Ok so I’m not crazy (well no more so than usual). Thank you!
:smiley:

:ahh:

These exist for a reason!


Double.isNaN(double)
Double.isInfinite(double)

Calling two negatively phrased language-dependent methods is better than one comparison? If there were an isFinite() method, I would consider using it.

Better than using x==x, which seems hacky and is surely platform/implementation dependent. It’s better not to introduce hard-to-diagnose bugs in your code.