Mir Random [WIP]
John Colvin via Digitalmars-d
digitalmars-d at puremagic.com
Thu Nov 24 04:02:22 PST 2016
On Thursday, 24 November 2016 at 10:41:44 UTC, Kagamin wrote:
> On Thursday, 24 November 2016 at 10:16:11 UTC, John Colvin
> wrote:
>> I was talking about andrei's example. He has a cast(int) in it
>> before the division.
>
> And you think that compilation of cast(int)a.length/2 to 3
> instructions is optimized just fine? How is it better that one
> shift?
Because it's correct. If a.length is larger than int.max then
cast(int)a.length will half the time be negative and therefore a
simple rightshift would not be equivalent to division by 2.
More information about the Digitalmars-d
mailing list