From: Skybuck Flying on
I guess the moral of this story is:

Delphi's Overflow/Range checking cannot be trusted at all...

I already knew it was bad and missed some cases... but this is getting
pretty ridicules! ;) :)

It even detects cases/"fake bugs" which seem totally legal and therefore
shouldn't have been detected at all ?! wow ?! ;) :)

None-the-less it always helps having it on... but it should not be relied on
to detect everything.

Bye,
Skybuck =D


From: Skybuck Flying on
My advice will be:

Create test programs which test full ranges, and have independent code which
test for correct input, correct memory and correct output value's... bit by
bit if necessary.

Such test programs will catch all cases.

I already created such a test program to test my WriteBitfield routines...
and the test program proved to be highly successfull and usefull ! =D

Bye,
Skybuck.


From: Chad on
On May 25, 6:54 am, "Skybuck Flying" <IntoTheFut...(a)hotmail.com>
wrote:
> My advice will be:
>
> Create test programs which test full ranges, and have independent code which
> test for correct input, correct memory and correct output value's... bit by
> bit if necessary.
>
> Such test programs will catch all cases.
>
> I already created such a test program to test my WriteBitfield routines....
> and the test program proved to be highly successfull and usefull ! =D
>


<off topic>
I can't tell if you are holding a conversation with yourself or if the
computers at my job are just doing some kind of wierd filtering that
isn't allowing me to see who you are talking to.
</off topic>

From: James Harris on
On 25 May, 16:51, Andy 'Krazy' Glew <ag-n...(a)patten-glew.net> wrote:
....
> When shifts are slow, instruction sets are advised to have instructions to generate bitmasks.
>
> dest := bitmask(frombit,tobit)
>
> but even these have 2 6 bit constants (on a 64 bit machine).
>
> dest := bitmask(bitpos6,len)
>
> not much better, except for small masks.

Right. For what the OP is looking for (rightmost N bits set) a simple
lookup table would do.

James
From: Skybuck Flying on

"James Harris" <james.harris.1(a)googlemail.com> wrote in message
news:de444692-fb87-4c7e-9831-c10ae147ab7e(a)v18g2000vbc.googlegroups.com...
> On 25 May, 16:51, Andy 'Krazy' Glew <ag-n...(a)patten-glew.net> wrote:
> ...
>> When shifts are slow, instruction sets are advised to have instructions
>> to generate bitmasks.
>>
>> dest := bitmask(frombit,tobit)
>>
>> but even these have 2 6 bit constants (on a 64 bit machine).
>>
>> dest := bitmask(bitpos6,len)
>>
>> not much better, except for small masks.
>
> Right. For what the OP is looking for (rightmost N bits set) a simple
> lookup table would do.

Seems like a waste of L1 data cache to me... it will already be massively
used me thinks...

I could be wrong though...

None the less, the lookup table method is idea another way to do it, I have
seen it before...

LookupTable : array[0..32] of longword;

^ BitCount goes into it as the index and a longword goes out with a maximum
of 32 bits ;)

So that'll be number 5. I'll have to consult my "source "databas"" to see
who's name it was who's I first saw ! ;) :)

Bye,
Skybuck.