11 public const float E = 2.7182817f;
13 public const float PI = 3.1415927f;
17 private static readonly
float[]
roundPower10Single =
new float[7] { 1f, 10f, 100f, 1000f, 10000f, 100000f, 1000000f };
21 public static extern float Acos(
float x);
25 public static extern float Acosh(
float x);
29 public static extern float Asin(
float x);
33 public static extern float Asinh(
float x);
37 public static extern float Atan(
float x);
41 public static extern float Atanh(
float x);
45 public static extern float Atan2(
float y,
float x);
49 public static extern float Cbrt(
float x);
53 public static extern float Ceiling(
float x);
57 public static extern float Cos(
float x);
61 public static extern float Cosh(
float x);
65 public static extern float Exp(
float x);
69 public static extern float Floor(
float x);
77 public static extern int ILogB(
float x);
81 public static extern float Log(
float x);
85 public static extern float Log2(
float x);
89 public static extern float Log10(
float x);
93 public static extern float Pow(
float x,
float y);
97 public static extern float Sin(
float x);
109 public static extern float Sinh(
float x);
113 public static extern float Sqrt(
float x);
117 public static extern float Tan(
float x);
121 public static extern float Tanh(
float x);
124 private unsafe static extern float ModF(
float x,
float* intptr);
127 private unsafe static extern void SinCos(
float x,
float* sin,
float* cos);
130 public static float Abs(
float x)
138 if ((num & 0x7F800000) >= 2139095040)
140 if (num != 2139095040)
144 return float.MaxValue;
150 num += ((num < 0) ? 1 : (-1));
157 if ((num & 0x7F800000) >= 2139095040)
163 return float.MinValue;
165 if (num ==
int.MinValue)
167 return float.Epsilon;
169 num += ((num >= 0) ? 1 : (-1));
180 return SoftwareFallback(x, y);
181 static float SoftwareFallback(
float x,
float y)
186 num2 &=
int.MinValue;
202 if (
float.IsNaN(num))
206 if (num == 0f &&
float.IsNegative(x))
210 float num2 = num -
Abs(y) * (float)
Sign(x);
211 if (
Abs(num2) ==
Abs(num))
214 float x3 =
Round(x2);
228 public static float Log(
float x,
float y)
242 if (x != 1f && (y == 0f ||
float.IsPositiveInfinity(y)))
250 public static float Max(
float x,
float y)
259 if (num > num2 ||
float.IsNaN(num))
265 if (!
float.IsNegative(x))
275 public static float Min(
float x,
float y)
284 if (num < num2 ||
float.IsNaN(num))
290 if (!
float.IsNegative(x))
329 int num2 =
float.ExtractExponentFromBits(num);
336 float x2 = ((num2 == 126 &&
float.ExtractSignificandFromBits(num) != 0) ? 1f : 0f);
343 uint num3 = (uint)(1 << 150 - num2);
344 uint num4 = num3 - 1;
346 num = (((num & num4) != 0) ? (num & ~num4) : (num & ~num3));
351 public static float Round(
float x,
int digits)
359 return Round(x, 0, mode);
364 if (digits < 0 || digits > 6)
368 if (mode < MidpointRounding.ToEven || mode >
MidpointRounding.ToPositiveInfinity)
372 if (
Abs(x) < 100000000f)
383 float x2 =
ModF(x, &x);
386 x += (float)
Sign(x2);
408 public static int Sign(
float x)
419 public static float ScaleB(
float x,
int n)
424 num *= 1.7014118E+38f;
428 num *= 1.7014118E+38f;
438 num *= 1.9721523E-31f;
442 num *= 1.9721523E-31f;
static unsafe float Int32BitsToSingle(int value)
static unsafe int SingleToInt32Bits(float value)
static uint SingleToUInt32Bits(float value)
static float UInt32BitsToSingle(uint value)
static unsafe void SinCos(float x, float *sin, float *cos)
static float Abs(float x)
static float Log(float x)
static unsafe float Truncate(float x)
static float ReciprocalEstimate(float x)
static float MinMagnitude(float x, float y)
static float ScaleB(float x, int n)
static float Log2(float x)
static float Max(float x, float y)
static float Atan(float x)
static float Acosh(float x)
static float FusedMultiplyAdd(float x, float y, float z)
static float Atan2(float y, float x)
static float Sqrt(float x)
static float BitIncrement(float x)
static unsafe float Round(float x, int digits, MidpointRounding mode)
static float MaxMagnitude(float x, float y)
static float Pow(float x, float y)
static float Min(float x, float y)
static float Log10(float x)
static float Round(float x, int digits)
static float Asinh(float x)
static float Acos(float x)
static float Cos(float x)
static float Sinh(float x)
static float ReciprocalSqrtEstimate(float x)
static float Asin(float x)
static float Round(float x, MidpointRounding mode)
static float Atanh(float x)
static float Cbrt(float x)
static float Cosh(float x)
static float IEEERemainder(float x, float y)
static float BitDecrement(float x)
static unsafe float ModF(float x, float *intptr)
static float CopySign(float x, float y)
static unsafe(float Sin, float Cos) SinCos(float x)
static float Log(float x, float y)
static float Ceiling(float x)
static float Sin(float x)
static float Floor(float x)
static float Exp(float x)
static float Tan(float x)
static float Tanh(float x)
static readonly float[] roundPower10Single
static int ILogB(float x)
static float Round(float x)
static byte Min(byte val1, byte val2)
static double Abs(double value)
static int Sign(decimal value)
static byte Max(byte val1, byte val2)
static Vector128< float > ConditionalSelectBitwise(Vector128< float > selector, Vector128< float > ifTrue, Vector128< float > ifFalse)
static new bool IsSupported
static new bool IsSupported
static unsafe Vector128< byte > CreateScalarUnsafe(byte value)
static new bool IsSupported
static Vector128< float > ReciprocalScalar(Vector128< float > value)
static Vector128< float > ReciprocalSqrtScalar(Vector128< float > value)
static string ArgumentOutOfRange_RoundingDigits_MathF
static string Format(string resourceFormat, object p1)
static string Argument_InvalidEnumValue