Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ben Pfaff <blp@cs.stanford.edu> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Question |
| Date | 2011-06-08 10:54 -0700 |
| Message-ID | <87y61cky4a.fsf@blp.benpfaff.org> (permalink) |
| References | <cbbad7e4-3532-4062-b39e-e4ad92a34f9d@p13g2000yqh.googlegroups.com> <8739jkmdin.fsf@blp.benpfaff.org> <e2ce4af8-9fb7-459c-88f6-58764f24f6b8@g12g2000yqd.googlegroups.com> |
Mateusz_madi <madi.czadi@gmail.com> writes: > if char is 8 bit long so -1 is : 1111 1111 > and i assign it to int which let's say is 32 bit long, shoudn't int > look like: 0000 0000 0000 1111 ? No. Type conversions in C preserve value, not bit pattern. If you assign -1, of any integer type, to an object with any other signed integer type, the destination will have value -1. I don't understand how you'd come up with the bit pattern that you suggested anyway. You wrote a total of 16 bits (not 32), and you only made 4 of them 1-bits (not 8). -- Ben Pfaff http://benpfaff.org
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Question Mateusz_madi <madi.czadi@gmail.com> - 2011-06-08 10:31 -0700
Re: Question Ben Pfaff <blp@cs.stanford.edu> - 2011-06-08 10:36 -0700
Re: Question Mateusz_madi <madi.czadi@gmail.com> - 2011-06-08 10:49 -0700
Re: Question Ben Pfaff <blp@cs.stanford.edu> - 2011-06-08 10:54 -0700
Re: Question Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-06-08 12:49 -0600
Re: Question Keith Thompson <kst-u@mib.org> - 2011-06-08 11:55 -0700
Re: Question Ben Pfaff <blp@cs.stanford.edu> - 2011-06-08 12:21 -0700
Re: Question "Kleuskes & Moos" <kleuske@xs4all.nl> - 2011-06-08 16:02 -0700
Re: Question Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-06-08 17:31 -0600
Re: Question Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2011-06-08 17:30 -0600
Re: Question Peter Nilsson <airia@acay.com.au> - 2011-06-08 16:34 -0700
Re: Question "Morris Keesan" <mkeesan@post.harvard.edu> - 2011-06-08 16:52 -0400
Re: Question Ben Pfaff <blp@cs.stanford.edu> - 2011-06-08 13:54 -0700
Re: Question "J. J. Farrell" <jjf@bcs.org.uk> - 2011-06-09 03:22 +0100
Re: Question Keith Thompson <kst-u@mib.org> - 2011-06-08 10:47 -0700
csiph-web