DConf 2014 talks slides

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 10 17:15:57 PDT 2014


On 08/11/2014 01:26 AM, Era Scarecrow wrote:
>   While we're on the topic of slides and it's slightly related, Walter
> Bright brought up an example of code that showed poor optimization that
> the compiler should be doing. Like using bit shifts to do
> multiply/divide by a power of 2.
>
>   i/8  vs  i>>3

Note that for signed types, the two are not the same.
i/8 rounds towards 0, while i>>3 rounds towards min:

static assert(-1/8==0);
static assert(-1>>3==-1);


More information about the Digitalmars-d mailing list