Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Tim Rentsch <txr@alumni.caltech.edu> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: unsigned int |
| Date | 2016-08-01 07:27 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <kfn37molg2w.fsf@x-alumni2.alumni.caltech.edu> (permalink) |
| References | <unsigned-20160731163521@ram.dialup.fu-berlin.de> <kfnshupl6se.fsf@x-alumni2.alumni.caltech.edu> <slrn3vfsnptpcs.ssv.ike@iceland.freeshell.org> |
Ike Naar <ike@iceland.freeshell.org> writes: > On 2016-07-31, Tim Rentsch <txr@alumni.caltech.edu> wrote: >> The most obvious difference between signed types and unsigned >> types (not counting that only signed types can be negative) is >> that operating on and converting to unsigned types is always >> defined behavior, whereas operating on or converting to signed >> types is sometimes undefined or implementation-defined behavior. > > Nit: a shift operation on unsigned types has undefined behavour if > the value of the right operand is greater than or equal to the > width of the promoted left operand (6.5.7p3). Yes, and that is worth pointing out. I subconsciously put it in a different category, because the abstract operation (or maybe I should say "abstract operation") isn't defined for such shift values. But it is undefined behavior, as are divide by zero and remainder by zero. Is that a complete list? Off the top of my head I can't think of any others. Converting from floating point to an unsigned type can (IIANM) give undefined behavior, but I don't think of that as an operation on an unsigned type.
Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: unsigned int Tim Rentsch <txr@alumni.caltech.edu> - 2016-07-31 16:36 -0700
Re: unsigned int Ike Naar <ike@iceland.freeshell.org> - 2016-08-01 06:01 +0000
Re: unsigned int Tim Rentsch <txr@alumni.caltech.edu> - 2016-08-01 07:27 -0700
csiph-web