为了让创造性的果汁流动,我将提供更多的例子。。。
public static double Raise(double this x, double exponent)
{
return Math.Pow(x, exponent);
}
public static bool NearZero(double this x, double tolerance)
{
return Math.Abs(x) <= tolerance;
}
public static double Cap(double this x, double threshold)
{
return Math.Abs(x)<threshold ? x : threshold*Math.Sign(x);
}
public static double SignOf(double this x, double sense)
{
return Math.Sign(sense)*Math.Abs(x);
}
public static double ToRadians(double this x) { return Math.PI*x/180; }
public static double ToDegrees(double this x) { return 180*x/Math.PI; }