View Single Post
  #7   Spotlight this post!  
Unread 22-06-2002, 01:54
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,573
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
when you cast the char to an unsigned int, the char sign extends. This goes back to that twos compelement stuff and all that junk that you probably don't want to understand. If you do want to understand, you know how to get a hold of me, though :-p

here is a hack that works, hopefully someone with more C/C++ experience then me knows a more elegant solution

Code:
#include <iostream>
using namespace std;

#define MAX <?

void main(void)
{
   unsigned char i = 255;

   cout << (i MAX 255) << endl;
}
I'll leave it to you to see if you can figure out why it works ;-)

Last edited by Joe Ross : 22-06-2002 at 01:56.