digitalmars.D.learn - std.math.modf
Spacen Jasset <spacen yahoo.co.uk> writes:
From the documentation: real modf(real x, ref real y); why is y a ref parameter? http://www.digitalmars.com/d/1.0/phobos/std_math.html
Mar 19 2008
Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes:
Spacen Jasset wrote:From the documentation: real modf(real x, ref real y); why is y a ref parameter? http://www.digitalmars.com/d/1.0/phobos/std_math.html
Apparently it doesn't do what it says it does. The implementation simply calls std.c.math.modfl(x, &y), which is documented at <http://www.opengroup.org/onlinepubs/000095399/functions/modf.html>. Apparently, std.math.modf(x,y), which is documented to return the remainder of (x / y), actually returns the fractional part of x, storing the integral part in y (so it never even *reads* y). Now, I can't remember ever using anything in std.math that takes > 1 parameter (mostly abs, sqrt, etc.) and haven't even executed modf(), but this seems to be a bug in either the documentation or the implementation of this function. Cross-posted to d.D.bugs & follow-up set.
Mar 19 2008