Thread: Floats
View Single Post
  #5   Spotlight this post!  
Unread 02-02-2005, 01:24
Unsung FIRST Hero
miketwalker miketwalker is offline
Robot Lifeguard
FRC #1902 (Exploding Bacon)
 
Join Date: Dec 2001
Rookie Year: 2002
Location: Orlando, FL
Posts: 878
miketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond reputemiketwalker has a reputation beyond repute
Send a message via AIM to miketwalker
Re: Floats

Quote:
Originally Posted by Dave Flowerday
One trick that we use frequently is to take a 16-bit number and treat the lower 8 bits as a fractional portion. That way you can stick with simple integer math operations but still obtain higher accuracy. We've done this with all of our distance calculations from wheel encoders, angle calculations from the gyro, PID controls, etc. There are always tradeoffs where using floats is justified and a decent idea. I think Dave was trying to make the point that (like any compromise) you just need to be smart about it and not make the decision without taking some time to consider the consequences.
That sounds like a good idea. Could you show me an example of what you mean? I don't know how you can treat the lower 8 bits as a fractional portion.

I agree with you about the tradeoffs certainly, that's why I was posting this thread before I got too deep to see if there were any alternatives and where I'll start hitting problems at if I don't. Thanks!