| delorie.com/archives/browse.cgi | search |
| Message-Id: | <199808042331.AAA02691@sable.ox.ac.uk> |
| Comments: | Authenticated sender is <mert0407 AT sable DOT ox DOT ac DOT uk> |
| From: | George Foot <george DOT foot AT merton DOT oxford DOT ac DOT uk> |
| To: | Hooman Katirai <hkatirai AT netpart DOT com> |
| Date: | Wed, 5 Aug 1998 00:30:30 +0000 |
| MIME-Version: | 1.0 |
| Subject: | Re: Possible bit shifting bug ... |
| Reply-to: | george DOT foot AT merton DOT oxford DOT ac DOT uk |
| CC: | djgpp AT delorie DOT com |
On 4 Aug 98 at 14:53, Hooman Katirai wrote:
> The following program gives this output. It is as if no bit shifting is
> taking place. I recompiled it as a c program and the same results were
> obtained:
>
> Program:
>
> #include <iostream.h>
> main() {
> int j=1;
> for (int i=0; i<16; i++) {
> cout << j;
> j << 1;
> }
> }
>
> The output is only a series of '1's. No bitshifting ever took place.
I think you meant "j <<= 1;".
> Guess I'll just have to multiply by two ... until the fix.
> Thanks for your time
Writing "j * 2;" wouldn't have any effect either ;). You need the
assignment: "j *= 2;".
--
george DOT foot AT merton DOT oxford DOT ac DOT uk
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |