Author: Dieter Buerssner
Date: 09:08:05 06/07/04
Go up one level in this thread
On June 07, 2004 at 11:11:37, Heiner Marxen wrote: >No. I've used this kind of shifts to assert that the type "int" can contain >a certain amount of bits. Heiner, I agree with other things you said, but this seems not so easy possible in Standard C (or I don't get your idea). From the draft of the C99 Standard: --- 6.5.7 Bitwise shift operators Syntax 1 shift-expression: additive-expression shift-expression << additive-expression shift-expression >> additive-expression Constraints 2 Each of the operands shall have integer type. Semantics 3 The integer promotions are performed on each of the operands. The type of the result is that of the promoted left operand. If the value of the right operand is negative or is greater than or equal to the width of the promoted left operand, the behavior is undefined. --- The last sentence ... Shifting by one less, than the width of the promoted left operand could be used, of course. But I would not call it "this kind of shifts" in the context of this discussion. Wouldn't be using limits.h easier, anyway? Regards, Dieter
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.