View Single Post
  #10   Spotlight this post!  
Unread 13-02-2005, 20:44
AIBob's Avatar
AIBob AIBob is offline
AI Programmer
AKA: Bob Frank DOT org
FRC #0358 (Hauppauge Robotic Eagles)
Team Role: Alumni
 
Join Date: Jan 2005
Rookie Year: 2003
Location: Long Island, NY (in Binghamton now)
Posts: 297
AIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to beholdAIBob is a splendid one to behold
Send a message via ICQ to AIBob Send a message via AIM to AIBob Send a message via MSN to AIBob Send a message via Yahoo to AIBob
Re: joystick sensitivity

Quote:
Originally Posted by Alan Anderson
Not so. For two reasons, the first of which is very important:

Negative numbers are not stored in sign-magnitude form. They are in "two's-complement" form. The value -1 masked with 0x7F yields a value of 127, a far cry from the expected 1.

(The second reason is that && is a logical operator, giving a true or false result. The arithmetic and is represented by a single &.)

The simplest syntax I know of for an absolute value function uses the ternary if operator. It's cryptic, but effective:
Code:
(value<0?-value:value)
Ok.... for some reason it worked for me in my code though.... but I suppose it will not work for absolute values...
Thanks for letting me know.
__________________
- from B B frank


Last edited by AIBob : 13-02-2005 at 21:58.