A more general bsr/bsf implementation

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Sun Apr 12 10:16:24 PDT 2015


On Sun, 12 Apr 2015 15:21:24 +0000, Johan Engelen wrote:

>>> 2) Is the current sign-extend up to size_t's width really intended
>>> behavior?
>>
>> It's due to integer promotions, so it should only influence bsr (when
>> it is called with a signed type.)
> 
> Sorry for not being clear.
> I understand why the current bsr behaves like it does, but what I meant
> is whether that is the desired behavior of bsr:
>      bsr( byte(-1) ) == 31  (32-bit size_t)
>      bsr( byte(-1) ) == 63  (64-bit size_t)
> instead of
>      bsr( byte(-1) ) == 7

i'd say that with explicitly given type it should be 7. but i don't know 
if it will break any code in druntime/phobos...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150412/eabda8ce/attachment-0001.sig>


More information about the Digitalmars-d mailing list