home *** CD-ROM | disk | FTP | other *** search
- From: bright@Data-IO.COM (Walter Bright)
-
- In article <498@longway.TIC.COM> uunet!stealth.acf.nyu.edu!brnstnd (Dan Bernstein) writes:
- <I'd like a solution that is both conformant and
- <portable in the real world.
- <Does (int) (unsigned int) ch do the trick?
- No.
-
- <What about (int) (unsigned char)?
- Yes, assuming chars are 8 bits. But be warned, some older K&R compilers I've
- run across do not do that cast correctly, even though the expression is correct.
-
- I prefer using:
- char c;
- int i;
- i = c & 0xFF; /* assuming chars >= 8 bits */
-
- P.S. I don't care about 1's complement machines.
-
- Volume-Number: Volume 18, Number 12
-
-