Author: Robert Hyatt
Date: 20:17:48 01/23/02
Go up one level in this thread
On January 23, 2002 at 16:04:09, Miguel A. Ballicora wrote: >On January 23, 2002 at 12:58:34, Robert Hyatt wrote: > >>On January 23, 2002 at 00:59:58, Eugene Nalimov wrote: >> >>>On January 23, 2002 at 00:22:12, Robert Hyatt wrote: >>> >>>>On January 22, 2002 at 12:22:15, Leen Ammeraal wrote: >>>> >>>>>Hi Miguel, >>>>>I tested Dann's version, LOWBIT, not your routine. >>>>>I forgot to write that I admire >>>>>this almost magical algorithm very much and that I would >>>>>be very pleased if someone could explain it. >>>> >>>> >>>>The idea is very simple. Test the end of the 64 bit value that has >>>>bits 32-63 with a bit scan instruction (which will give a result of >>>>0-31. Add 32 to this to adjust to 32-63. Now test the other end. If >>>>the bit scan finds no bits set, it will leave the dest register unchanged >>>>which leaves the result of your high-order end in there. If it does find >>>>a bit set (0-31) it will overwrite the destination and the result will be >>>>0-31. >>>> >>>>Works well. Not quite so easy to do for "hibit" as a branch is going to >>>>be necessary... >>> >>>Unfortunately, Intel's documentation does not say "Unchanged if there is no bit >>>set". It says "Undefined". Maybe on the current CPUs it works, but I strongly >>>recommend against such tricks. >>> >>>Eugene >> >>I know. And I agree. It is just like depending on chars to be signed >>when the ANSI standard doesn't dictate this. And yes, I have been burned > >Just for the record, it is slighlty different because if the chars are signed or >not it is "implementation defined" rather than "undefined". At least there you >can be safe if you use the same compiler all the time. Here you cannot be safe >of anything. > >Miguel You can't even be safe with the same compiler. The vendor can change this behavior any time he chooses, since the "spec" doesn't "specify" what he must do. About the most stupid decision from a "standards" committee I can think of... Maybe not specifying whether a for loop is _always_ executed at least once or may never execute would have been better...
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.