[Issue 5900] std.math.radians(), std.math.degrees()
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Apr 28 01:51:19 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5900
kennytm at gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kennytm at gmail.com
--- Comment #3 from kennytm at gmail.com 2011-04-28 01:47:32 PDT ---
(In reply to comment #2)
> It's worse than that. A bigger issue is that it encourages the wrong approach.
> These functions would encourage people to write wrong code like this:
> sin(degreesToRadians(360));
> Which gives the wrong answer -- sin(360degrees) should be EXACTLY zero, not a
> small nonsense value like 1.4534e-17.
> I don't think it's fair to trick people like that.
>
> The correct way to do trig with degrees is: sin( ((x%360.0)/180)*PI );
> I'll put this in the docs for std.math, since it's not obvious.
Well maybe *this* is the function that should be added instead of degrees().
T degrees(alias f)(T theta) if (isFloatingPoint!T && f is sin ...) {
return f( (theta % 360.0) / 180 * PI );
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list