[phobos] Proposed changes to std.math + introduce std.mathspecial

Andrei Alexandrescu andrei at erdani.com
Wed Nov 17 14:31:16 PST 2010


On 11/17/10 1:56 PM, Simen Kjaeraas wrote:
> David Simcha <dsimcha at gmail.com> wrote:
>
>>> (1) Add two necessary functions to std.math:
>>>
>>> // Rounds x to the nearest int or long using the currently selected
>>> rounding mode
>>> // (MUCH faster than cast(int)).
>>>
>>
>> Why isn't this the default, i.e. why doesn't cast(int) do this?
>
> Second this. If it's not so complex Walter can't possibly understand it,
> or it may cause bees to spurt from your floppy drive, it sounds like
> what cast(int) should do.

cast(int) always truncates, whereas Don's function uses the current 
rounding mode.

Andrei


More information about the phobos mailing list