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

Jonathan M Davis jmdavisProg at gmx.com
Wed Nov 17 14:54:07 PST 2010


On Wednesday, November 17, 2010 14:31:16 Andrei Alexandrescu wrote:
> 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.

Then the question is whether there is a way to do what Don did, only have it 
truncate, and still have that sort of speed increase. If there is, then that's 
probably what cast(int) should do. If not, then cast(int) should be left as is.

- Jonathan M Davis


More information about the phobos mailing list