March 19, 2008 std.math.modf | ||||
---|---|---|---|---|
| ||||
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 |
March 19, 2008 Re: std.math.modf | ||||
---|---|---|---|---|
| ||||
Posted in reply to Spacen Jasset | 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. |
Copyright © 1999-2021 by the D Language Foundation