Thread: Floats
View Single Post
  #12   Spotlight this post!  
Unread 02-02-2005, 12:45
Chris Hibner's Avatar Unsung FIRST Hero
Chris Hibner Chris Hibner is offline
Eschewing Obfuscation Since 1990
AKA: Lars Kamen's Roadie
FRC #0051 (Wings of Fire)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1997
Location: Canton, MI
Posts: 1,488
Chris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond repute
Re: Floats

Quote:
Originally Posted by miketwalker
I was curious if anybody has any idea on this... but about how many floats can you get away with using before you start running into problems?
Sorry for not responding earlier.

Floats are generally not a good thing in embedded programming. Granted, it's a little late for you this year, but I am presenting an Advanced C Programming topic at the Conference in Atlanta. In the presentation I will be covering fixed-point math (i.e. implementing fractions with only integer data types). If you are using floats, I would suggest coming and checking out the presentation.

In the mean time, I would suggest searching the web for "fixed point math". It's probably a little late to change your code for this year, but you can get a head start for next year.

Just as a side note, our autonomous controller from last year (and this year) mapped the field with X,Y coordinates to a calculation accuracy of less than one inch (of course our real accuracy depended highly on the sensor calibrations, but the calculation accuracy was good). We had to use trig (sin and cos) to do the mapping, and arctan to do a go-to X,Y command. EVERYTHING was done using fixed-point math with integer data types. 95% was done with 16-bit variables and the stuff that needed higher precision was done with 32-bit variables. We've NEVER used a float (that statement is also true for everything we do at work). So, it can be done as long as you know what you're doing.
__________________
-
An ounce of perception is worth a pound of obscure.

Last edited by Chris Hibner : 02-02-2005 at 12:54.