[Issue 2636] std.math.pow should be a template

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 30 10:57:20 PST 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2636





------- Comment #2 from schveiguy at yahoo.com  2009-01-30 12:57 -------
(In reply to comment #1)
> I had the following in my tree for a while, just committed it now so you can
> look at it:
> 
> F pow(F)(F x, uint n) if (isFloatingPoint!(F))
> F pow(F)(F x, int n) if (isFloatingPoint!(F))
> F pow(F)(F x, F y) if (isFloatingPoint!(F))
> 
> Would this be enough?

Is returning F a legitimate concern?  Generally when one is working with one
type, one tends to stick with that type, but you would lose precision, as the
actual implementation does return a real.  I'd say it's ok to return F instead
of real, but others might disagree.

But in general, your implementation is probably viable for D2, but not for D1. 
D1 Tango can at least be fixed, if Walter nixes fixing D1 phobos (even though
this is a fix that does not change the API).


-- 



More information about the Digitalmars-d-bugs mailing list