View Single Post
  #2   Spotlight this post!  
Unread 03-28-2016, 07:50 PM
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,536
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
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).
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.

Last edited by GeeTwo : 03-28-2016 at 07:53 PM.
Reply With Quote