Number of Bits Needed to Represent a Zero-Offset Integer

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jan 19 12:54:50 PST 2015


On 1/19/15 3:46 PM, "Nordlöw" wrote:
> On Monday, 19 January 2015 at 13:30:47 UTC, Steven Schveighoffer wrote:
>> http://dlang.org/phobos/core_bitop.html#.bsr
>>
>> It's actually an intrinsic, reduces to an instruction. Mind the
>> requirements for 0.
>
> This works for me
>
> https://github.com/nordlow/justd/blob/master/traits_ex.d#L406

Cool. I would point out that the commented code suggests you should be 
handling the 0 case, but you are not (when T.min == T.max)

-Steve


More information about the Digitalmars-d-learn mailing list