home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / std_unix / volume.18 / text0011.txt < prev    next >
Encoding:
Internet Message Format  |  1990-03-18  |  621 b 

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