Thread: Robot Drifting
View Single Post
  #3   Spotlight this post!  
Unread 15-02-2004, 12:00
Mark McLeod's Avatar
Mark McLeod Mark McLeod is offline
Just Itinerant
AKA: Hey dad...Father...MARK
FRC #0358 (Robotic Eagles)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Hauppauge, Long Island, NY
Posts: 8,856
Mark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond reputeMark McLeod has a reputation beyond repute
Re: Robot Drifting

Quote:
Originally Posted by steven114
Might I point out that 150/100 will evaluate to 1, not 1.5... there is no way to store a floating point number in an integer. You can hack around it by storing an exponent, but I don't believe setting myInt to 150/100 will store 1.5...
#define's don't evaluate expressions.
You don't evaluate (150/100). You evaluate (x * 150 / 100).
To get a floating point effect you do all your multiplication first, then all your division.

In integer math,e.g.,

x = 150/100 * 100 = 100
but
x = 100 * 150 / 100 = 150

Just be careful to type cast the expression to the largest size you need, e.g., using all char for the above will return an incorrect result.
__________________
"Rationality is our distinguishing characteristic - it's what sets us apart from the beasts." - Aristotle

Last edited by Mark McLeod : 15-02-2004 at 13:59.