shift left arithmetic

Tim Bomgardner bomgard at copper.ucs.indiana.edu
Tue Sep 11 09:16:04 AEST 1990


In article <2101 at charon.cwi.nl> aeb at cwi.nl (Andries Brouwer) writes:
}vu0310 at bingvaxu.cc.binghamton.edu (R. Kym Horsell) writes:
}
}#>While debugging an Australian computer algebra package
}#>I stumbled over the following: 1<<32 produced 0, but
}#>int a; a=1; a<<32 produced 1. (Of course the word length
}
}#Compiler (may not be) broken -- try 1L<<32. (You didn't
}#say that the size of _int_'s was 32 bits).
}
}True, but in fact it was, and 1<<32 and 1L<<32 produce the same results.

For those who might be interested:

Microsoft C (5.1) produced different results depending on the use of 16
or 32 bit integers, but at least one case would always produce a
non-zero result.  Turbo C 2.0 always produced 0's in all cases.



More information about the Comp.lang.c mailing list