RFC: Units of measurement for D (Phobos?)

David Nadlinger see at klickverbot.at
Fri Apr 15 06:29:23 PDT 2011


On 4/15/11 3:06 PM, Simen Kjaeraas wrote:
> Oh, and it would appear I have found a bug:
>
> enum foo = metre / 2;
> std\units.d(165): Error: cannot raise int to a negative integer power. Did you m
> ean (cast(real)rhs)^^-1 ?

Oh, thanks, I just pushed a fix (which uses (rhs ^^ 0) / rhs to work 
around the issue for integer types).

Be aware, however, that your code might not be what you want – the value 
type is inferred to int, and thus the result is 0 * metre…

David


More information about the Digitalmars-d mailing list