www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Feature requests

reply Spacen Jasset <spacenjasset yahoo.co.uk> writes:
I have some features requests, some of which are small. Is there a way 
that these should be raised?

For example, this trivial feature could go in phobos2.std.math and tango:

float degToRad(float deg)
{
	return deg * PI / 180;
}

float radToDeg(float rad)
{
	return (180 * rad) / PI;
}
Apr 01 2008
parent reply Derek Parnell <derek psych.ward> writes:
On Tue, 01 Apr 2008 16:35:30 +0100, Spacen Jasset wrote:

Or maybe ...

enum
{
   fPI_180 = PI / 180.0L;
   f180_PI = 180.0L / PI;
}

T degToRad(T)(T deg)
{
	return cast(T)(cast(real)deg * fPI_180);
}
 
T radToDeg(T)(T rad)
{
	return cast(T)(cast(real)rad * f180_PI);
}


-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell
Apr 01 2008
parent Spacen Jasset <spacenjasset yahoo.co.uk> writes:
Derek Parnell wrote:
 On Tue, 01 Apr 2008 16:35:30 +0100, Spacen Jasset wrote:
 
 Or maybe ...
 
 enum
 {
    fPI_180 = PI / 180.0L;
    f180_PI = 180.0L / PI;
 }
 
 T degToRad(T)(T deg)
 {
 	return cast(T)(cast(real)deg * fPI_180);
 }
  
 T radToDeg(T)(T rad)
 {
 	return cast(T)(cast(real)rad * f180_PI);
 }
 
 
Yes, thereby giving answers in terms of float, doublt or real. How would that be different from just implementing in terms of real anyway. reals can be implictly converted down to a floats anyway, can they not? Seems like I should post this to digitalmars.D
Apr 02 2008