Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!rutgers!cmcl2!kramden.acf.nyu.edu!brnstnd From: brnstnd@kramden.acf.nyu.edu (Dan Bernstein) Newsgroups: comp.lang.c Subject: Re: binary to ascii Message-ID: <13752:Sep1510:09:4190@kramden.acf.nyu.edu> Date: 15 Sep 90 10:09:41 GMT References: <371@bally.Bally.COM> <574@demott.COM> <13680@hydra.gatech.EDU> Distribution: usa Organization: IR Lines: 13 In article <13680@hydra.gatech.EDU> cc100aa@prism.gatech.EDU (Ray Spalding) writes: > In article <574@demott.COM> kdq@demott.COM (Kevin D. Quitt) writes: > >In article <371@bally.Bally.COM> siva@bally.Bally.COM (Siva Chelliah) writes: [ i = ((int) c) & 0x00FF ] > > Try "i = (unsigned int) c;" and you'll see it isn't necessary. > This is incorrect (where c is a signed char). We discussed this a few months ago (``How to convert a char into an int from 0 to 255?''). The conclusion was that (int) (unsigned char) c takes a character into an integer from 0 through UCHAR_MAX. Other series of casts do not do the job; using & is overkill. ---Dan