gnormhurst
22-03-2004, 14:02
'splain this, somebody:
#define STRAIGHT_DRIVE_DIRECTION ( 127 + 30 )
static int steeringValue = 0;
. . .
steeringValue = (int) ((STRAIGHT_DRIVE_DIRECTION));
printf( "nav: DTC %3d ", steeringValue );
That printed a value of -99! Why?
Changing the assignment to:
steeringValue = (int) ((unsigned char) (STRAIGHT_DRIVE_DIRECTION));
made it print "157" as expected the first time.
Is this weird, or is there something about type casting I don't understand?
#define STRAIGHT_DRIVE_DIRECTION ( 127 + 30 )
static int steeringValue = 0;
. . .
steeringValue = (int) ((STRAIGHT_DRIVE_DIRECTION));
printf( "nav: DTC %3d ", steeringValue );
That printed a value of -99! Why?
Changing the assignment to:
steeringValue = (int) ((unsigned char) (STRAIGHT_DRIVE_DIRECTION));
made it print "157" as expected the first time.
Is this weird, or is there something about type casting I don't understand?