View Single Post
  #3   Spotlight this post!  
Unread 13-02-2015, 16:18
cstelter cstelter is offline
Programming Mentor
AKA: Craig Stelter
FRC #3018 (Nordic Storm)
Team Role: Mentor
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Mankato, MN
Posts: 77
cstelter will become famous soon enough
Re: Some thoughts about Double Precision numbers

Quote:
Originally Posted by Oromus View Post
I'll just say, as the poster of the "if (distance != 6)" line, that I wrote it with the fact that unless the double is exactly 6 that it will run in mind. That's because it led to a PID loop that contained a double-based deadzone, so I didn't write see the point in writing a deadzone for 6 when the PID already had a deadzone.
Hi Oromus-- in retrospect I suppose I shouldn't have used exactly your line to start the new thread. Apologies about that.

But I do see red flags whenever I see code that compares doubles for equality or inequality. I thought I'd post what I believe to be a very good rule of thumb about floating point numbers. Maybe some will disagree with my take and a nice discussion will erupt. Otherwise, perhaps folks will look at comparisons of floating point numbers a bit more carefully and code better robots as a result.

I don't really agree with your assertions above, but this thread isn't the place for that discussion, so maybe I'll send you a PM about my thoughts. I still think that should have been a red flag for you, but probably for entirely different reasons than you suspect.
Reply With Quote