![]() |
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 |
Re: Autonomous Problems / I'm dumb
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). |
Re: Autonomous Problems / I'm dumb
Ok so I'm not crazy (well no more so than usual). Thank you!
:D |
Re: Autonomous Problems / I'm dumb
Quote:
These exist for a reason! Code:
Double.isNaN(double) |
Re: Autonomous Problems / I'm dumb
Calling two negatively phrased language-dependent methods is better than one comparison? If there were an isFinite() method, I would consider using it.
|
Re: Autonomous Problems / I'm dumb
Quote:
|
| All times are GMT -5. The time now is 07:24 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi