On Friday, 24 January 2014 at 22:59:08 UTC, Andrei Alexandrescu wrote:
integral expressions are handled. For example I found it ridiculous that unary "-" for uint returns uint. Walter talked

Fortunately most CPUS have ones-complement so the result is correct if you only use one unsigned type.

-$01 == (~$01)+1
-$01 == $ff
 $ff+$03 == ($102)&($ff)
 $ff+$03 == $02

This is useful for interpolating oscillators (going from 1 to 0, or 0 to 1)

ulong phase, delta;
...
phase += delta;
sample1 = wavetable[phase>>16];
sample2 = wavetable[(phase>>16) + 1];
return interpolate16bit(sample1,sample2,phase&0xffff);

It is the automatic promoting of unsigned types that is a C-language bug IMHO.

Reply via email to