Author: Robert Hyatt
Date: 14:33:06 06/07/04
Go up one level in this thread
On June 07, 2004 at 13:05:34, Heiner Marxen wrote: >On June 07, 2004 at 12:08:05, Dieter Buerssner wrote: > >>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 ... > >Yes, you are right, of course. >This sentence is exactly what I was referring to, >but "I've used this kind of shifts" does in fact not be literally correct. >Sorry, Uri, for being a bit too harsh. > >What I really do is shifting an initial 1u by a single bit, until it vanishes, >counting the shifted bits. > >>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. > >Yes, yes. My fault. > >>Wouldn't be using limits.h easier, anyway? > >Well, when it is there and is reliable... yes. >So, nowadays you are right: using "limits.h" is ok. I ran on an older IBM RS6000 last year. This was not reliable. I won't begin to comment on which version of AIX was running, I don't remember. I was doing a Unix/C training course for the local phone company and when our original unix box I used in class crashed and burned, they quickly dropped this RS6000 in its place, and it caused a few quirks as I talked about limits.h as one angle to the portability issues they wanted the course to address. I quickly broke out my linux laptop and all was well. :) > >My programming practice with C reaches back up to the '70s, >so I still know about (and sometimes use) the pre-ANSI practices. > >>Regards, >>Dieter > >Cheers, >Heiner
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.