| delorie.com/archives/browse.cgi | search |
| From: | Daniel Barker <sokal AT holyrood DOT ed DOT ac DOT uk> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: shifting left, and shifting right... |
| Date: | Wed, 21 Jul 1999 10:53:40 +0100 |
| Organization: | Edinburgh University |
| Lines: | 22 |
| Message-ID: | <379598A4.2D30C907@holyrood.ed.ac.uk> |
| References: | <37937D02 DOT 5D28D561 AT geocities DOT com> <7n0mc8$382$1 AT newssrv DOT otenet DOT gr> |
| NNTP-Posting-Host: | dialup-115.publab.ed.ac.uk |
| Mime-Version: | 1.0 |
| X-Trace: | scotsman.ed.ac.uk 932550712 18324 129.215.38.115 (21 Jul 1999 09:51:52 GMT) |
| X-Complaints-To: | usenet AT scotsman DOT ed DOT ac DOT uk |
| NNTP-Posting-Date: | 21 Jul 1999 09:51:52 GMT |
| X-Mailer: | Mozilla 4.51 [en] (Win98; I) |
| X-Accept-Language: | en |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
Pavlos wrote: [good explanation of bitwise operations snipped] I'd just like to add three warnings. (1) Do not right shift a variable of a signed type. The result is implementation-defined in C if the variable has a negative value. (2) With an n-bit quantity, do not shift by more than n-1. e.g., do not shift athe value of a 32-bit type more than 31, either to left or right. The result is undefined in C. (3) Do not attempt to shift by a negative number of bits. The result is undefined in C. Source: Kernighan & Ritchie, 2nd edition, Section A7.8; see also Section 2.9. -- Daniel Barker.
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |