1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
6 using System.Collections.Generic;
8 #pragma warning disable xUnit1025 // reporting duplicate test cases due to not distinguishing 0.0 from -0.0
10 namespace System.Tests
12 public static class MathFTests
14 // binary32 (float) has a machine epsilon of 2^-23 (approx. 1.19e-07). However, this
15 // is slightly too accurate when writing tests meant to run against libm implementations
16 // for various platforms. 2^-21 (approx. 4.76e-07) seems to be as accurate as we can get.
18 // The tests themselves will take CrossPlatformMachineEpsilon and adjust it according to the expected result
19 // so that the delta used for comparison will compare the most significant digits and ignore
20 // any digits that are outside the single precision range (6-9 digits).
22 // For example, a test with an expect result in the format of 0.xxxxxxxxx will use
23 // CrossPlatformMachineEpsilon for the variance, while an expected result in the format of 0.0xxxxxxxxx
24 // will use CrossPlatformMachineEpsilon / 10 and expected result in the format of x.xxxxxx will
25 // use CrossPlatformMachineEpsilon * 10.
26 private const float CrossPlatformMachineEpsilon = 4.76837158e-07f;
28 // The existing estimate functions either have an error of no more than 1.5 * 2^-12 (approx. 3.66e-04)
29 // or perform one Newton-Raphson iteration which, for the currently tested values, gives an error of
30 // no more than approx. 1.5 * 2^-7 (approx 1.17e-02).
31 private const double CrossPlatformMachineEpsilonForEstimates = 1.171875e-02f;
33 /// <summary>Verifies that two <see cref="float"/> values are equal, within the <paramref name="variance"/>.</summary>
34 /// <param name="expected">The expected value</param>
35 /// <param name="actual">The value to be compared against</param>
36 /// <param name="variance">The total variance allowed between the expected and actual results.</param>
37 /// <exception cref="EqualException">Thrown when the values are not equal</exception>
38 private static void AssertEqual(float expected, float actual, float variance)
40 if (float.IsNaN(expected))
42 if (float.IsNaN(actual))
47 throw new EqualException(ToStringPadded(expected), ToStringPadded(actual));
49 else if (float.IsNaN(actual))
51 throw new EqualException(ToStringPadded(expected), ToStringPadded(actual));
54 if (float.IsNegativeInfinity(expected))
56 if (float.IsNegativeInfinity(actual))
61 throw new EqualException(ToStringPadded(expected), ToStringPadded(actual));
63 else if (float.IsNegativeInfinity(actual))
65 throw new EqualException(ToStringPadded(expected), ToStringPadded(actual));
68 if (float.IsPositiveInfinity(expected))
70 if (float.IsPositiveInfinity(actual))
75 throw new EqualException(ToStringPadded(expected), ToStringPadded(actual));
77 else if (float.IsPositiveInfinity(actual))
79 throw new EqualException(ToStringPadded(expected), ToStringPadded(actual));
82 if (IsNegativeZero(expected))
84 if (IsNegativeZero(actual))
89 if (IsPositiveZero(variance) || IsNegativeZero(variance))
91 throw new EqualException(ToStringPadded(expected), ToStringPadded(actual));
94 // When the variance is not +-0.0, then we are handling a case where
95 // the actual result is expected to not be exactly -0.0 on some platforms
96 // and we should fallback to checking if it is within the allowed variance instead.
98 else if (IsNegativeZero(actual))
100 if (IsPositiveZero(variance) || IsNegativeZero(variance))
102 throw new EqualException(ToStringPadded(expected), ToStringPadded(actual));
105 // When the variance is not +-0.0, then we are handling a case where
106 // the actual result is expected to not be exactly -0.0 on some platforms
107 // and we should fallback to checking if it is within the allowed variance instead.
110 if (IsPositiveZero(expected))
112 if (IsPositiveZero(actual))
117 if (IsPositiveZero(variance) || IsNegativeZero(variance))
119 throw new EqualException(ToStringPadded(expected), ToStringPadded(actual));
122 // When the variance is not +-0.0, then we are handling a case where
123 // the actual result is expected to not be exactly +0.0 on some platforms
124 // and we should fallback to checking if it is within the allowed variance instead.
126 else if (IsPositiveZero(actual))
128 if (IsPositiveZero(variance) || IsNegativeZero(variance))
130 throw new EqualException(ToStringPadded(expected), ToStringPadded(actual));
133 // When the variance is not +-0.0, then we are handling a case where
134 // the actual result is expected to not be exactly +0.0 on some platforms
135 // and we should fallback to checking if it is within the allowed variance instead.
138 var delta = MathF.Abs(actual - expected);
140 if (delta > variance)
142 throw new EqualException(ToStringPadded(expected), ToStringPadded(actual));
146 private static unsafe bool IsNegativeZero(float value)
148 return (*(uint*)(&value)) == 0x80000000;
151 private static unsafe bool IsPositiveZero(float value)
153 return (*(uint*)(&value)) == 0x00000000;
156 // We have a custom ToString here to ensure that edge cases (specifically +-0.0,
157 // but also NaN and +-infinity) are correctly and consistently represented.
158 private static string ToStringPadded(float value)
160 if (float.IsNaN(value))
162 return "NaN".PadLeft(10);
164 else if (float.IsPositiveInfinity(value))
166 return "+\u221E".PadLeft(10);
168 else if (float.IsNegativeInfinity(value))
170 return "-\u221E".PadLeft(10);
172 else if (IsNegativeZero(value))
174 return "-0.0".PadLeft(10);
176 else if (IsPositiveZero(value))
178 return "+0.0".PadLeft(10);
182 return $"{value,10:G9}";
187 public static void E()
189 Assert.Equal(0x402DF854, BitConverter.SingleToInt32Bits(MathF.E));
193 public static void Pi()
195 Assert.Equal(0x40490FDB, BitConverter.SingleToInt32Bits(MathF.PI));
199 public static void Tau()
201 Assert.Equal(0x40C90FDB, BitConverter.SingleToInt32Bits(MathF.Tau));
205 [InlineData(float.NegativeInfinity, float.PositiveInfinity, 0.0f)]
206 [InlineData(-3.14159265f, 3.14159265f, CrossPlatformMachineEpsilon * 10)] // value: -(pi) expected: (pi)
207 [InlineData(-2.71828183f, 2.71828183f, CrossPlatformMachineEpsilon * 10)] // value: -(e) expected: (e)
208 [InlineData(-2.30258509f, 2.30258509f, CrossPlatformMachineEpsilon * 10)] // value: -(ln(10)) expected: (ln(10))
209 [InlineData(-1.57079633f, 1.57079633f, CrossPlatformMachineEpsilon * 10)] // value: -(pi / 2) expected: (pi / 2)
210 [InlineData(-1.44269504f, 1.44269504f, CrossPlatformMachineEpsilon * 10)] // value: -(log2(e)) expected: (log2(e))
211 [InlineData(-1.41421356f, 1.41421356f, CrossPlatformMachineEpsilon * 10)] // value: -(sqrt(2)) expected: (sqrt(2))
212 [InlineData(-1.12837917f, 1.12837917f, CrossPlatformMachineEpsilon * 10)] // value: -(2 / sqrt(pi)) expected: (2 / sqrt(pi))
213 [InlineData(-1.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
214 [InlineData(-0.785398163f, 0.785398163f, CrossPlatformMachineEpsilon)] // value: -(pi / 4) expected: (pi / 4)
215 [InlineData(-0.707106781f, 0.707106781f, CrossPlatformMachineEpsilon)] // value: -(1 / sqrt(2)) expected: (1 / sqrt(2))
216 [InlineData(-0.693147181f, 0.693147181f, CrossPlatformMachineEpsilon)] // value: -(ln(2)) expected: (ln(2))
217 [InlineData(-0.636619772f, 0.636619772f, CrossPlatformMachineEpsilon)] // value: -(2 / pi) expected: (2 / pi)
218 [InlineData(-0.434294482f, 0.434294482f, CrossPlatformMachineEpsilon)] // value: -(log10(e)) expected: (log10(e))
219 [InlineData(-0.318309886f, 0.318309886f, CrossPlatformMachineEpsilon)] // value: -(1 / pi) expected: (1 / pi)
220 [InlineData(-0.0f, 0.0f, 0.0f)]
221 [InlineData(float.NaN, float.NaN, 0.0f)]
222 [InlineData(0.0f, 0.0f, 0.0f)]
223 [InlineData(0.318309886f, 0.318309886f, CrossPlatformMachineEpsilon)] // value: (1 / pi) expected: (1 / pi)
224 [InlineData(0.434294482f, 0.434294482f, CrossPlatformMachineEpsilon)] // value: (log10(e)) expected: (log10(e))
225 [InlineData(0.636619772f, 0.636619772f, CrossPlatformMachineEpsilon)] // value: (2 / pi) expected: (2 / pi)
226 [InlineData(0.693147181f, 0.693147181f, CrossPlatformMachineEpsilon)] // value: (ln(2)) expected: (ln(2))
227 [InlineData(0.707106781f, 0.707106781f, CrossPlatformMachineEpsilon)] // value: (1 / sqrt(2)) expected: (1 / sqrt(2))
228 [InlineData(0.785398163f, 0.785398163f, CrossPlatformMachineEpsilon)] // value: (pi / 4) expected: (pi / 4)
229 [InlineData(1.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
230 [InlineData(1.12837917f, 1.12837917f, CrossPlatformMachineEpsilon * 10)] // value: (2 / sqrt(pi)) expected: (2 / sqrt(pi))
231 [InlineData(1.41421356f, 1.41421356f, CrossPlatformMachineEpsilon * 10)] // value: (sqrt(2)) expected: (sqrt(2))
232 [InlineData(1.44269504f, 1.44269504f, CrossPlatformMachineEpsilon * 10)] // value: (log2(e)) expected: (log2(e))
233 [InlineData(1.57079633f, 1.57079633f, CrossPlatformMachineEpsilon * 10)] // value: (pi / 2) expected: (pi / 2)
234 [InlineData(2.30258509f, 2.30258509f, CrossPlatformMachineEpsilon * 10)] // value: (ln(10)) expected: (ln(10))
235 [InlineData(2.71828183f, 2.71828183f, CrossPlatformMachineEpsilon * 10)] // value: (e) expected: (e)
236 [InlineData(3.14159265f, 3.14159265f, CrossPlatformMachineEpsilon * 10)] // value: (pi) expected: (pi)
237 [InlineData(float.PositiveInfinity, float.PositiveInfinity, 0.0f)]
238 public static void Abs(float value, float expectedResult, float allowedVariance)
240 AssertEqual(expectedResult, MathF.Abs(value), allowedVariance);
244 [InlineData(float.NegativeInfinity, float.NaN, 0.0f)]
245 [InlineData(-3.14159265f, float.NaN, 0.0f)] // value: -(pi)
246 [InlineData(-2.71828183f, float.NaN, 0.0f)] // value: -(e)
247 [InlineData(-1.41421356f, float.NaN, 0.0f)] // value: -(sqrt(2))
248 [InlineData(-1.0f, 3.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: (pi)
249 [InlineData(-0.911733915f, 2.71828183f, CrossPlatformMachineEpsilon * 10)] // expected: (e)
250 [InlineData(-0.668201510f, 2.30258509f, CrossPlatformMachineEpsilon * 10)] // expected: (ln(10))
251 [InlineData(-0.0f, 1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: (pi / 2)
252 [InlineData(float.NaN, float.NaN, 0.0f)]
253 [InlineData(0.0f, 1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: (pi / 2)
254 [InlineData(0.127751218f, 1.44269504f, CrossPlatformMachineEpsilon * 10)] // expected: (log2(e))
255 [InlineData(0.155943695f, 1.41421356f, CrossPlatformMachineEpsilon * 10)] // expected: (sqrt(2))
256 [InlineData(0.428125148f, 1.12837917f, CrossPlatformMachineEpsilon * 10)] // expected: (2 / sqrt(pi))
257 [InlineData(0.540302306f, 1.0f, CrossPlatformMachineEpsilon * 10)]
258 [InlineData(0.707106781f, 0.785398163f, CrossPlatformMachineEpsilon)] // expected: (pi / 4), value: (1 / sqrt(2))
259 [InlineData(0.760244597f, 0.707106781f, CrossPlatformMachineEpsilon)] // expected: (1 / sqrt(2))
260 [InlineData(0.769238901f, 0.693147181f, CrossPlatformMachineEpsilon)] // expected: (ln(2))
261 [InlineData(0.804109828f, 0.636619772f, CrossPlatformMachineEpsilon)] // expected: (2 / pi)
262 [InlineData(0.907167129f, 0.434294482f, CrossPlatformMachineEpsilon)] // expected: (log10(e))
263 [InlineData(0.949765715f, 0.318309886f, CrossPlatformMachineEpsilon)] // expected: (1 / pi)
264 [InlineData(1.0f, 0.0f, 0.0f)]
265 [InlineData(1.41421356f, float.NaN, 0.0f)] // value: (sqrt(2))
266 [InlineData(2.71828183f, float.NaN, 0.0f)] // value: (e)
267 [InlineData(3.14159265f, float.NaN, 0.0f)] // value: (pi)
268 [InlineData(float.PositiveInfinity, float.NaN, 0.0f)]
269 public static void Acos(float value, float expectedResult, float allowedVariance)
271 AssertEqual(expectedResult, MathF.Acos(value), allowedVariance);
275 [InlineData(float.NegativeInfinity, float.NaN, 0.0f)]
276 [InlineData(-3.14159265f, float.NaN, 0.0f)] // value: -(pi)
277 [InlineData(-2.71828183f, float.NaN, 0.0f)] // value: -(e)
278 [InlineData(-1.41421356f, float.NaN, 0.0f)] // value: -(sqrt(2))
279 [InlineData(-1.0f, float.NaN, 0.0f)]
280 [InlineData(-0.693147181f, float.NaN, 0.0f)] // value: -(ln(2))
281 [InlineData(-0.434294482f, float.NaN, 0.0f)] // value: -(log10(e))
282 [InlineData(-0.0f, float.NaN, 0.0f)]
283 [InlineData(float.NaN, float.NaN, 0.0f)]
284 [InlineData(0.0f, float.NaN, 0.0f)]
285 [InlineData(1.0f, 0.0f, CrossPlatformMachineEpsilon)]
286 [InlineData(1.05108979f, 0.318309886f, CrossPlatformMachineEpsilon)] // expected: (1 / pi)
287 [InlineData(1.09579746f, 0.434294482f, CrossPlatformMachineEpsilon)] // expected: (log10(e))
288 [InlineData(1.20957949f, 0.636619772f, CrossPlatformMachineEpsilon)] // expected: (2 / pi)
289 [InlineData(1.25f, 0.693147181f, CrossPlatformMachineEpsilon)] // expected: (ln(2))
290 [InlineData(1.26059184f, 0.707106781f, CrossPlatformMachineEpsilon)] // expected: (1 / sqrt(2))
291 [InlineData(1.32460909f, 0.785398163f, CrossPlatformMachineEpsilon)] // expected: (pi / 4)
292 [InlineData(1.54308063f, 1.0, CrossPlatformMachineEpsilon * 10)]
293 [InlineData(1.70710014f, 1.12837917f, CrossPlatformMachineEpsilon * 10)] // expected: (2 / sqrt(pi))
294 [InlineData(2.17818356f, 1.41421356f, CrossPlatformMachineEpsilon * 10)] // expected: (sqrt(2))
295 [InlineData(2.23418810f, 1.44269504f, CrossPlatformMachineEpsilon * 10)] // expected: (log2(e))
296 [InlineData(2.50917848f, 1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: (pi / 2)
297 [InlineData(5.05f, 2.30258509f, CrossPlatformMachineEpsilon * 10)] // expected: (ln(10))
298 [InlineData(7.61012514f, 2.71828183f, CrossPlatformMachineEpsilon * 10)] // expected: (e)
299 [InlineData(11.5919533f, 3.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: (pi)
300 [InlineData(float.PositiveInfinity, float.PositiveInfinity, 0.0f)]
301 public static void Acosh(float value, float expectedResult, float allowedVariance)
303 AssertEqual(expectedResult, MathF.Acosh(value), allowedVariance);
307 [InlineData(float.NegativeInfinity, float.NaN, 0.0f)]
308 [InlineData(-3.14159265f, float.NaN, 0.0f)] // value: -(pi)
309 [InlineData(-2.71828183f, float.NaN, 0.0f)] // value: -(e)
310 [InlineData(-1.41421356f, float.NaN, 0.0f)] // value: -(sqrt(2))
311 [InlineData(-1.0f, -1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi / 2)
312 [InlineData(-0.991806244f, -1.44269504f, CrossPlatformMachineEpsilon * 10)] // expected: -(log2(e))
313 [InlineData(-0.987765946f, -1.41421356f, CrossPlatformMachineEpsilon * 10)] // expected: -(sqrt(2))
314 [InlineData(-0.903719457f, -1.12837917f, CrossPlatformMachineEpsilon * 10)] // expected: -(2 / sqrt(pi))
315 [InlineData(-0.841470985f, -1.0f, CrossPlatformMachineEpsilon * 10)]
316 [InlineData(-0.743980337f, -0.839007561f, CrossPlatformMachineEpsilon)] // expected: -(pi - ln(10))
317 [InlineData(-0.707106781f, -0.785398163f, CrossPlatformMachineEpsilon)] // expected: -(pi / 4), value: (1 / sqrt(2))
318 [InlineData(-0.649636939f, -0.707106781f, CrossPlatformMachineEpsilon)] // expected: -(1 / sqrt(2))
319 [InlineData(-0.638961276f, -0.693147181f, CrossPlatformMachineEpsilon)] // expected: -(ln(2))
320 [InlineData(-0.594480769f, -0.636619772f, CrossPlatformMachineEpsilon)] // expected: -(2 / pi)
321 [InlineData(-0.420770483f, -0.434294482f, CrossPlatformMachineEpsilon)] // expected: -(log10(e))
322 [InlineData(-0.410781291f, -0.423310825f, CrossPlatformMachineEpsilon)] // expected: -(pi - e)
323 [InlineData(-0.312961796f, -0.318309886f, CrossPlatformMachineEpsilon)] // expected: -(1 / pi)
324 [InlineData(-0.0f, -0.0f, 0.0f)]
325 [InlineData(float.NaN, float.NaN, 0.0f)]
326 [InlineData(0.0f, 0.0f, 0.0f)]
327 [InlineData(0.312961796f, 0.318309886f, CrossPlatformMachineEpsilon)] // expected: (1 / pi)
328 [InlineData(0.410781291f, 0.423310825f, CrossPlatformMachineEpsilon)] // expected: (pi - e)
329 [InlineData(0.420770483f, 0.434294482f, CrossPlatformMachineEpsilon)] // expected: (log10(e))
330 [InlineData(0.594480769f, 0.636619772f, CrossPlatformMachineEpsilon)] // expected: (2 / pi)
331 [InlineData(0.638961276f, 0.693147181f, CrossPlatformMachineEpsilon)] // expected: (ln(2))
332 [InlineData(0.649636939f, 0.707106781f, CrossPlatformMachineEpsilon)] // expected: (1 / sqrt(2))
333 [InlineData(0.707106781f, 0.785398163f, CrossPlatformMachineEpsilon)] // expected: (pi / 4), value: (1 / sqrt(2))
334 [InlineData(0.743980337f, 0.839007561f, CrossPlatformMachineEpsilon)] // expected: (pi - ln(10))
335 [InlineData(0.841470985f, 1.0f, CrossPlatformMachineEpsilon * 10)]
336 [InlineData(0.903719457f, 1.12837917f, CrossPlatformMachineEpsilon * 10)] // expected: (2 / sqrt(pi))
337 [InlineData(0.987765946f, 1.41421356f, CrossPlatformMachineEpsilon * 10)] // expected: (sqrt(2))
338 [InlineData(0.991806244f, 1.44269504f, CrossPlatformMachineEpsilon * 10)] // expected: (log2(e))
339 [InlineData(1.0f, 1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: (pi / 2)
340 [InlineData(1.41421356f, float.NaN, 0.0f)] // value: (sqrt(2))
341 [InlineData(2.71828183f, float.NaN, 0.0f)] // value: (e)
342 [InlineData(3.14159265f, float.NaN, 0.0f)] // value: (pi)
343 [InlineData(float.PositiveInfinity, float.NaN, 0.0f)]
344 public static void Asin(float value, float expectedResult, float allowedVariance)
346 AssertEqual(expectedResult, MathF.Asin(value), allowedVariance);
350 [InlineData(float.NegativeInfinity, float.NegativeInfinity, 0.0f)]
351 [InlineData(-11.5487394f, -3.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi)
352 [InlineData(-7.54413710f, -2.71828183f, CrossPlatformMachineEpsilon * 10)] // expected: -(e)
353 [InlineData(-4.95f, -2.30258509f, CrossPlatformMachineEpsilon * 10)] // expected: -(ln(10))
354 [InlineData(-2.30129890f, -1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi / 2)
355 [InlineData(-1.99789801f, -1.44269504f, CrossPlatformMachineEpsilon * 10)] // expected: -(log2(e))
356 [InlineData(-1.93506682f, -1.41421356f, CrossPlatformMachineEpsilon * 10)] // expected: -(sqrt(2))
357 [InlineData(-1.38354288f, -1.12837917f, CrossPlatformMachineEpsilon * 10)] // expected: -(2 / sqrt(pi))
358 [InlineData(-1.17520119f, -1.0f, CrossPlatformMachineEpsilon * 10)]
359 [InlineData(-0.868670961f, -0.785398163f, CrossPlatformMachineEpsilon)] // expected: -(pi / 4)
360 [InlineData(-0.767523145f, -0.707106781f, CrossPlatformMachineEpsilon)] // expected: -(1 / sqrt(2))
361 [InlineData(-0.75f, -0.693147181f, CrossPlatformMachineEpsilon)] // expected: -(ln(2))
362 [InlineData(-0.680501678f, -0.636619772f, CrossPlatformMachineEpsilon)] // expected: -(2 / pi)
363 [InlineData(-0.448075979f, -0.434294482f, CrossPlatformMachineEpsilon)] // expected: -(log10(e))
364 [InlineData(-0.323712439f, -0.318309886f, CrossPlatformMachineEpsilon)] // expected: -(1 / pi)
365 [InlineData(-0.0f, -0.0, 0.0f)]
366 [InlineData(float.NaN, float.NaN, 0.0f)]
367 [InlineData(0.0f, 0.0, 0.0f)]
368 [InlineData(0.323712439f, 0.318309886f, CrossPlatformMachineEpsilon)] // expected: (1 / pi)
369 [InlineData(0.448075979f, 0.434294482f, CrossPlatformMachineEpsilon)] // expected: (log10(e))
370 [InlineData(0.680501678f, 0.636619772f, CrossPlatformMachineEpsilon)] // expected: (2 / pi)
371 [InlineData(0.75f, 0.693147181f, CrossPlatformMachineEpsilon)] // expected: (ln(2))
372 [InlineData(0.767523145f, 0.707106781f, CrossPlatformMachineEpsilon)] // expected: (1 / sqrt(2))
373 [InlineData(0.868670961f, 0.785398163f, CrossPlatformMachineEpsilon)] // expected: (pi / 4)
374 [InlineData(1.17520119f, 1.0f, CrossPlatformMachineEpsilon * 10)]
375 [InlineData(1.38354288f, 1.12837917f, CrossPlatformMachineEpsilon * 10)] // expected: (2 / sqrt(pi))
376 [InlineData(1.93506682f, 1.41421356f, CrossPlatformMachineEpsilon * 10)] // expected: (sqrt(2))
377 [InlineData(1.99789801f, 1.44269504f, CrossPlatformMachineEpsilon * 10)] // expected: (log2(e))
378 [InlineData(2.30129890f, 1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: (pi / 2)
379 [InlineData(4.95f, 2.30258509f, CrossPlatformMachineEpsilon * 10)] // expected: (ln(10))
380 [InlineData(7.54413710f, 2.71828183f, CrossPlatformMachineEpsilon * 10)] // expected: (e)
381 [InlineData(11.5487394f, 3.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: (pi)
382 [InlineData(float.PositiveInfinity, float.PositiveInfinity, 0.0f)]
383 public static void Asinh(float value, float expectedResult, float allowedVariance)
385 AssertEqual(expectedResult, MathF.Asinh(value), allowedVariance);
389 [InlineData(float.NegativeInfinity, -1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi / 2)
390 [InlineData(-7.76357567f, -1.44269504f, CrossPlatformMachineEpsilon * 10)] // expected: -(log2(e))
391 [InlineData(-6.33411917f, -1.41421356f, CrossPlatformMachineEpsilon * 10)] // expected: -(sqrt(2))
392 [InlineData(-2.11087684f, -1.12837917f, CrossPlatformMachineEpsilon * 10)] // expected: -(2 / sqrt(pi))
393 [InlineData(-1.55740772f, -1.0f, CrossPlatformMachineEpsilon * 10)]
394 [InlineData(-1.11340715f, -0.839007561f, CrossPlatformMachineEpsilon)] // expected: -(pi - ln(10))
395 [InlineData(-1.0f, -0.785398163f, CrossPlatformMachineEpsilon)] // expected: -(pi / 4)
396 [InlineData(-0.854510432f, -0.707106781f, CrossPlatformMachineEpsilon)] // expected: -(1 / sqrt(2))
397 [InlineData(-0.830640878f, -0.693147181f, CrossPlatformMachineEpsilon)] // expected: -(ln(2))
398 [InlineData(-0.739302950f, -0.636619772f, CrossPlatformMachineEpsilon)] // expected: -(2 / pi)
399 [InlineData(-0.463829067f, -0.434294482f, CrossPlatformMachineEpsilon)] // expected: -(log10(e))
400 [InlineData(-0.450549534f, -0.423310825f, CrossPlatformMachineEpsilon)] // expected: -(pi - e)
401 [InlineData(-0.329514733f, -0.318309886f, CrossPlatformMachineEpsilon)] // expected: -(1 / pi)
402 [InlineData(-0.0f, -0.0f, 0.0f)]
403 [InlineData(float.NaN, float.NaN, 0.0f)]
404 [InlineData(0.0f, 0.0f, 0.0f)]
405 [InlineData(0.329514733f, 0.318309886f, CrossPlatformMachineEpsilon)] // expected: (1 / pi)
406 [InlineData(0.450549534f, 0.423310825f, CrossPlatformMachineEpsilon)] // expected: (pi - e)
407 [InlineData(0.463829067f, 0.434294482f, CrossPlatformMachineEpsilon)] // expected: (log10(e))
408 [InlineData(0.739302950f, 0.636619772f, CrossPlatformMachineEpsilon)] // expected: (2 / pi)
409 [InlineData(0.830640878f, 0.693147181f, CrossPlatformMachineEpsilon)] // expected: (ln(2))
410 [InlineData(0.854510432f, 0.707106781f, CrossPlatformMachineEpsilon)] // expected: (1 / sqrt(2))
411 [InlineData(1.0f, 0.785398163f, CrossPlatformMachineEpsilon)] // expected: (pi / 4)
412 [InlineData(1.11340715f, 0.839007561f, CrossPlatformMachineEpsilon)] // expected: (pi - ln(10))
413 [InlineData(1.55740772f, 1.0f, CrossPlatformMachineEpsilon * 10)]
414 [InlineData(2.11087684f, 1.12837917f, CrossPlatformMachineEpsilon * 10)] // expected: (2 / sqrt(pi))
415 [InlineData(6.33411917f, 1.41421356f, CrossPlatformMachineEpsilon * 10)] // expected: (sqrt(2))
416 [InlineData(7.76357567f, 1.44269504f, CrossPlatformMachineEpsilon * 10)] // expected: (log2(e))
417 [InlineData(float.PositiveInfinity, 1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: (pi / 2)
418 public static void Atan(float value, float expectedResult, float allowedVariance)
420 AssertEqual(expectedResult, MathF.Atan(value), allowedVariance);
424 [InlineData(float.NegativeInfinity, -1.0f, -1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi / 2)
425 [InlineData(float.NegativeInfinity, -0.0f, -1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi / 2)
426 [InlineData(float.NegativeInfinity, float.NaN, float.NaN, 0.0f)]
427 [InlineData(float.NegativeInfinity, 0.0f, -1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi / 2)
428 [InlineData(float.NegativeInfinity, 1.0f, -1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi / 2)
429 [InlineData(-1.0f, -1.0f, -2.35619449f, CrossPlatformMachineEpsilon * 10)] // expected: -(3 * pi / 4)
430 [InlineData(-1.0f, -0.0f, -1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi / 2)
431 [InlineData(-1.0f, float.NaN, float.NaN, 0.0f)]
432 [InlineData(-1.0f, 0.0f, -1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi / 2)
433 [InlineData(-1.0f, 1.0f, -0.785398163f, CrossPlatformMachineEpsilon)] // expected: -(pi / 4)
434 [InlineData(-1.0f, float.PositiveInfinity, -0.0f, 0.0f)]
435 [InlineData(-0.991806244f, -0.127751218f, -1.69889761f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi - log2(e))
436 [InlineData(-0.991806244f, 0.127751218f, -1.44269504f, CrossPlatformMachineEpsilon * 10)] // expected: -(log2(e))
437 [InlineData(-0.987765946f, -0.155943695f, -1.72737909f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi - sqrt(2))
438 [InlineData(-0.987765946f, 0.155943695f, -1.41421356f, CrossPlatformMachineEpsilon * 10)] // expected: -(sqrt(2))
439 [InlineData(-0.903719457f, -0.428125148f, -2.01321349f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi - (2 / sqrt(pi))
440 [InlineData(-0.903719457f, 0.428125148f, -1.12837917f, CrossPlatformMachineEpsilon * 10)] // expected: -(2 / sqrt(pi)
441 [InlineData(-0.841470985f, -0.540302306f, -2.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi - 1)
442 [InlineData(-0.841470985f, 0.540302306f, -1.0f, CrossPlatformMachineEpsilon * 10)]
443 [InlineData(-0.743980337f, -0.668201510f, -2.30258509f, CrossPlatformMachineEpsilon * 10)] // expected: -(ln(10))
444 [InlineData(-0.743980337f, 0.668201510f, -0.839007561f, CrossPlatformMachineEpsilon)] // expected: -(pi - ln(10))
445 [InlineData(-0.707106781f, -0.707106781f, -2.35619449f, CrossPlatformMachineEpsilon * 10)] // expected: -(3 * pi / 4), y: -(1 / sqrt(2)) x: -(1 / sqrt(2))
446 [InlineData(-0.707106781f, 0.707106781f, -0.785398163f, CrossPlatformMachineEpsilon)] // expected: -(pi / 4), y: -(1 / sqrt(2)) x: (1 / sqrt(2))
447 [InlineData(-0.649636939f, -0.760244597f, -2.43448587f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi - (1 / sqrt(2))
448 [InlineData(-0.649636939f, 0.760244597f, -0.707106781f, CrossPlatformMachineEpsilon)] // expected: -(1 / sqrt(2))
449 [InlineData(-0.638961276f, -0.769238901f, -2.44844547f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi - ln(2))
450 [InlineData(-0.638961276f, 0.769238901f, -0.693147181f, CrossPlatformMachineEpsilon)] // expected: -(ln(2))
451 [InlineData(-0.594480769f, -0.804109828f, -2.50497288f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi - (2 / pi))
452 [InlineData(-0.594480769f, 0.804109828f, -0.636619772f, CrossPlatformMachineEpsilon)] // expected: -(2 / pi)
453 [InlineData(-0.420770483f, -0.907167129f, -2.70729817f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi - log10(e))
454 [InlineData(-0.420770483f, 0.907167129f, -0.434294482f, CrossPlatformMachineEpsilon)] // expected: -(log10(e))
455 [InlineData(-0.410781291f, -0.911733915f, -2.71828183f, CrossPlatformMachineEpsilon * 10)] // expected: -(e)
456 [InlineData(-0.410781291f, 0.911733915f, -0.423310825f, CrossPlatformMachineEpsilon)] // expected: -(pi - e)
457 [InlineData(-0.312961796f, -0.949765715f, -2.82328277f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi - (1 / pi))
458 [InlineData(-0.312961796f, 0.949765715f, -0.318309886f, CrossPlatformMachineEpsilon)] // expected: -(1 / pi)
459 [InlineData(-0.0f, float.NegativeInfinity, -3.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi)
460 [InlineData(-0.0f, -1.0f, -3.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi)
461 [InlineData(-0.0f, -0.0f, -3.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi)
462 [InlineData(-0.0f, float.NaN, float.NaN, 0.0f)]
463 [InlineData(-0.0f, 0.0f, -0.0f, 0.0f)]
464 [InlineData(-0.0f, 1.0f, -0.0f, 0.0f)]
465 [InlineData(-0.0f, float.PositiveInfinity, -0.0f, 0.0f)]
466 [InlineData(float.NaN, float.NegativeInfinity, float.NaN, 0.0f)]
467 [InlineData(float.NaN, -1.0f, float.NaN, 0.0f)]
468 [InlineData(float.NaN, -0.0f, float.NaN, 0.0f)]
469 [InlineData(float.NaN, float.NaN, float.NaN, 0.0f)]
470 [InlineData(float.NaN, 0.0f, float.NaN, 0.0f)]
471 [InlineData(float.NaN, 1.0f, float.NaN, 0.0f)]
472 [InlineData(float.NaN, float.PositiveInfinity, float.NaN, 0.0f)]
473 [InlineData(0.0f, float.NegativeInfinity, 3.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: (pi)
474 [InlineData(0.0f, -1.0f, 3.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: (pi)
475 [InlineData(0.0f, -0.0f, 3.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: (pi)
476 [InlineData(0.0f, float.NaN, float.NaN, 0.0f)]
477 [InlineData(0.0f, 0.0f, 0.0f, 0.0f)]
478 [InlineData(0.0f, 1.0f, 0.0f, 0.0f)]
479 [InlineData(0.0f, float.PositiveInfinity, 0.0f, 0.0f)]
480 [InlineData(0.312961796f, -0.949765715f, 2.82328277f, CrossPlatformMachineEpsilon * 10)] // expected: (pi - (1 / pi))
481 [InlineData(0.312961796f, 0.949765715f, 0.318309886f, CrossPlatformMachineEpsilon)] // expected: (1 / pi)
482 [InlineData(0.410781291f, -0.911733915f, 2.71828183f, CrossPlatformMachineEpsilon * 10)] // expected: (e)
483 [InlineData(0.410781291f, 0.911733915f, 0.423310825f, CrossPlatformMachineEpsilon)] // expected: (pi - e)
484 [InlineData(0.420770483f, -0.907167129f, 2.70729817f, CrossPlatformMachineEpsilon * 10)] // expected: (pi - log10(e))
485 [InlineData(0.420770483f, 0.907167129f, 0.434294482f, CrossPlatformMachineEpsilon)] // expected: (log10(e))
486 [InlineData(0.594480769f, -0.804109828f, 2.50497288f, CrossPlatformMachineEpsilon * 10)] // expected: (pi - (2 / pi))
487 [InlineData(0.594480769f, 0.804109828f, 0.636619772f, CrossPlatformMachineEpsilon)] // expected: (2 / pi)
488 [InlineData(0.638961276f, -0.769238901f, 2.44844547f, CrossPlatformMachineEpsilon * 10)] // expected: (pi - ln(2))
489 [InlineData(0.638961276f, 0.769238901f, 0.693147181f, CrossPlatformMachineEpsilon)] // expected: (ln(2))
490 [InlineData(0.649636939f, -0.760244597f, 2.43448587f, CrossPlatformMachineEpsilon * 10)] // expected: (pi - (1 / sqrt(2))
491 [InlineData(0.649636939f, 0.760244597f, 0.707106781f, CrossPlatformMachineEpsilon)] // expected: (1 / sqrt(2))
492 [InlineData(0.707106781f, -0.707106781f, 2.35619449f, CrossPlatformMachineEpsilon * 10)] // expected: (3 * pi / 4), y: (1 / sqrt(2)) x: -(1 / sqrt(2))
493 [InlineData(0.707106781f, 0.707106781f, 0.785398163f, CrossPlatformMachineEpsilon)] // expected: (pi / 4), y: (1 / sqrt(2)) x: (1 / sqrt(2))
494 [InlineData(0.743980337f, -0.668201510f, 2.30258509f, CrossPlatformMachineEpsilon * 10)] // expected: (ln(10))
495 [InlineData(0.743980337f, 0.668201510f, 0.839007561f, CrossPlatformMachineEpsilon)] // expected: (pi - ln(10))
496 [InlineData(0.841470985f, -0.540302306f, 2.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: (pi - 1)
497 [InlineData(0.841470985f, 0.540302306f, 1.0f, CrossPlatformMachineEpsilon * 10)]
498 [InlineData(0.903719457f, -0.428125148f, 2.01321349f, CrossPlatformMachineEpsilon * 10)] // expected: (pi - (2 / sqrt(pi))
499 [InlineData(0.903719457f, 0.428125148f, 1.12837917f, CrossPlatformMachineEpsilon * 10)] // expected: (2 / sqrt(pi))
500 [InlineData(0.987765946f, -0.155943695f, 1.72737909f, CrossPlatformMachineEpsilon * 10)] // expected: (pi - sqrt(2))
501 [InlineData(0.987765946f, 0.155943695f, 1.41421356f, CrossPlatformMachineEpsilon * 10)] // expected: (sqrt(2))
502 [InlineData(0.991806244f, -0.127751218f, 1.69889761f, CrossPlatformMachineEpsilon * 10)] // expected: (pi - log2(e))
503 [InlineData(0.991806244f, 0.127751218f, 1.44269504f, CrossPlatformMachineEpsilon * 10)] // expected: (log2(e))
504 [InlineData(1.0f, -1.0f, 2.35619449f, CrossPlatformMachineEpsilon * 10)] // expected: (3 * pi / 4)
505 [InlineData(1.0f, -0.0f, 1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: (pi / 2)
506 [InlineData(1.0f, float.NaN, float.NaN, 0.0f)]
507 [InlineData(1.0f, 0.0f, 1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: (pi / 2)
508 [InlineData(1.0f, 1.0f, 0.785398163f, CrossPlatformMachineEpsilon)] // expected: (pi / 4)
509 [InlineData(1.0f, float.PositiveInfinity, 0.0f, 0.0f)]
510 [InlineData(float.PositiveInfinity, -1.0f, 1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: (pi / 2)
511 [InlineData(float.PositiveInfinity, -0.0f, 1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: (pi / 2)
512 [InlineData(float.PositiveInfinity, float.NaN, float.NaN, 0.0f)]
513 [InlineData(float.PositiveInfinity, 0.0f, 1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: (pi / 2)
514 [InlineData(float.PositiveInfinity, 1.0f, 1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: (pi / 2)
515 public static void Atan2(float y, float x, float expectedResult, float allowedVariance)
517 AssertEqual(expectedResult, MathF.Atan2(y, x), allowedVariance);
521 [InlineData(float.NegativeInfinity, float.NegativeInfinity, -2.35619449f, CrossPlatformMachineEpsilon * 10)] // expected: -(3 * pi / 4)
522 [InlineData(float.NegativeInfinity, float.PositiveInfinity, -0.785398163f, CrossPlatformMachineEpsilon)] // expected: -(pi / 4)
523 [InlineData(float.PositiveInfinity, float.NegativeInfinity, 2.35619449f, CrossPlatformMachineEpsilon * 10)] // expected: (3 * pi / 4
524 [InlineData(float.PositiveInfinity, float.PositiveInfinity, 0.785398163f, CrossPlatformMachineEpsilon)] // expected: (pi / 4)
525 public static void Atan2_IEEE(float y, float x, float expectedResult, float allowedVariance)
527 AssertEqual(expectedResult, MathF.Atan2(y, x), allowedVariance);
531 [InlineData(float.NegativeInfinity, float.NaN, 0.0f)]
532 [InlineData(-3.14159265f, float.NaN, 0.0f)] // value: -(pi)
533 [InlineData(-2.71828183f, float.NaN, 0.0f)] // value: -(e)
534 [InlineData(-1.41421356f, float.NaN, 0.0f)] // value: -(sqrt(2))
535 [InlineData(-1.0f, float.NegativeInfinity, CrossPlatformMachineEpsilon * 10)]
536 [InlineData(-0.996272076f, -3.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi)
537 [InlineData(-0.991328916f, -2.71828183f, CrossPlatformMachineEpsilon * 10)] // expected: -(e)
538 [InlineData(-0.980198020f, -2.30258509f, CrossPlatformMachineEpsilon * 10)] // expected: -(ln(10))
539 [InlineData(-0.917152336f, -1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi / 2)
540 [InlineData(-0.894238946f, -1.44269504f, CrossPlatformMachineEpsilon * 10)] // expected: -(log2(e))
541 [InlineData(-0.888385562f, -1.41421356f, CrossPlatformMachineEpsilon * 10)] // expected: -(sqrt(2))
542 [InlineData(-0.810463806f, -1.12837917f, CrossPlatformMachineEpsilon * 10)] // expected: -(2 / sqrt(pi))
543 [InlineData(-0.761594156f, -1.0f, CrossPlatformMachineEpsilon * 10)]
544 [InlineData(-0.655794203f, -0.785398163f, CrossPlatformMachineEpsilon)] // expected: -(pi / 4)
545 [InlineData(-0.608859365f, -0.707106781f, CrossPlatformMachineEpsilon)] // expected: -(1 / sqrt(2))
546 [InlineData(-0.6f, -0.693147181f, CrossPlatformMachineEpsilon)] // expected: -(ln(2))
547 [InlineData(-0.562593600f, -0.636619772f, CrossPlatformMachineEpsilon)] // expected: -(2 / pi)
548 [InlineData(-0.408904012f, -0.434294482f, CrossPlatformMachineEpsilon)] // expected: -(log10(e))
549 [InlineData(-0.307977913f, -0.318309886f, CrossPlatformMachineEpsilon)] // expected: -(1 / pi)
550 [InlineData(-0.0f, -0.0f, 0.0f)]
551 [InlineData(float.NaN, float.NaN, 0.0f)]
552 [InlineData(0.0, 0.0f, 0.0f)]
553 [InlineData(0.307977913f, 0.318309886f, CrossPlatformMachineEpsilon)] // expected: (1 / pi)
554 [InlineData(0.408904012f, 0.434294482f, CrossPlatformMachineEpsilon)] // expected: (log10(e))
555 [InlineData(0.562593600f, 0.636619772f, CrossPlatformMachineEpsilon)] // expected: (2 / pi)
556 [InlineData(0.6f, 0.693147181f, CrossPlatformMachineEpsilon)] // expected: (ln(2))
557 [InlineData(0.608859365f, 0.707106781f, CrossPlatformMachineEpsilon)] // expected: (1 / sqrt(2))
558 [InlineData(0.655794203f, 0.785398163f, CrossPlatformMachineEpsilon)] // expected: (pi / 4)
559 [InlineData(0.761594156f, 1.0f, CrossPlatformMachineEpsilon * 10)]
560 [InlineData(0.810463806f, 1.12837917f, CrossPlatformMachineEpsilon * 10)] // expected: (2 / sqrt(pi))
561 [InlineData(0.888385562f, 1.41421356f, CrossPlatformMachineEpsilon * 10)] // expected: (sqrt(2))
562 [InlineData(0.894238946f, 1.44269504f, CrossPlatformMachineEpsilon * 10)] // expected: (log2(e))
563 [InlineData(0.917152336f, 1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: (pi / 2)
564 [InlineData(0.980198020f, 2.30258509f, CrossPlatformMachineEpsilon * 10)] // expected: (ln(10))
565 [InlineData(0.991328916f, 2.71828183f, CrossPlatformMachineEpsilon * 10)] // expected: (e)
566 [InlineData(0.996272076f, 3.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: (pi)
567 [InlineData(1.0f, float.PositiveInfinity, 0.0f)]
568 [InlineData(3.14159265f, float.NaN, 0.0f)] // value: (pi)
569 [InlineData(2.71828183f, float.NaN, 0.0f)] // value: (e)
570 [InlineData(1.41421356f, float.NaN, 0.0f)] // value: (sqrt(2))
571 [InlineData(float.PositiveInfinity, float.NaN, 0.0f)]
572 public static void Atanh(float value, float expectedResult, float allowedVariance)
574 AssertEqual(expectedResult, MathF.Atanh(value), allowedVariance);
578 [InlineData(float.NegativeInfinity, float.NegativeInfinity)]
579 [InlineData(-3.14159265f, -3.14159298f)] // value: -(pi)
580 [InlineData(-2.71828183f, -2.71828198f)] // value: -(e)
581 [InlineData(-2.30258509f, -2.30258536f)] // value: -(ln(10))
582 [InlineData(-1.57079633f, -1.57079649f)] // value: -(pi / 2)
583 [InlineData(-1.44269504f, -1.44269514f)] // value: -(log2(e))
584 [InlineData(-1.41421356f, -1.41421366f)] // value: -(sqrt(2))
585 [InlineData(-1.12837917f, -1.12837934f)] // value: -(2 / sqrt(pi))
586 [InlineData(-1.0f, -1.00000012f)]
587 [InlineData(-0.785398163f, -0.785398245f)] // value: -(pi / 4)
588 [InlineData(-0.707106781f, -0.707106829f)] // value: -(1 / sqrt(2))
589 [InlineData(-0.693147181f, -0.693147242f)] // value: -(ln(2))
590 [InlineData(-0.636619772f, -0.636619806f)] // value: -(2 / pi)
591 [InlineData(-0.434294482f, -0.434294522f)] // value: -(log10(e))
592 [InlineData(-0.318309886f, -0.318309903f)] // value: -(1 / pi)
593 [InlineData(-0.0f, -float.Epsilon)]
594 [InlineData(float.NaN, float.NaN)]
595 [InlineData(0.0f, -float.Epsilon)]
596 [InlineData(0.318309886f, 0.318309844f)] // value: (1 / pi)
597 [InlineData(0.434294482f, 0.434294462f)] // value: (log10(e))
598 [InlineData(0.636619772f, 0.636619687f)] // value: (2 / pi)
599 [InlineData(0.693147181f, 0.693147123f)] // value: (ln(2))
600 [InlineData(0.707106781f, 0.707106709f)] // value: (1 / sqrt(2))
601 [InlineData(0.785398163f, 0.785398126f)] // value: (pi / 4)
602 [InlineData(1.0f, 0.999999940f)]
603 [InlineData(1.12837917f, 1.12837911f)] // value: (2 / sqrt(pi))
604 [InlineData(1.41421356f, 1.41421342f)] // value: (sqrt(2))
605 [InlineData(1.44269504f, 1.44269490f)] // value: (log2(e))
606 [InlineData(1.57079633f, 1.57079625f)] // value: (pi / 2)
607 [InlineData(2.30258509f, 2.30258489f)] // value: (ln(10))
608 [InlineData(2.71828183f, 2.71828151f)] // value: (e)
609 [InlineData(3.14159265f, 3.14159250f)] // value: (pi)
610 [InlineData(float.PositiveInfinity, float.MaxValue)]
611 public static void BitDecrement(float value, float expectedResult)
613 AssertEqual(expectedResult, MathF.BitDecrement(value), 0.0f);
617 [InlineData(float.NegativeInfinity, float.MinValue)]
618 [InlineData(-3.14159265f, -3.14159250f)] // value: -(pi)
619 [InlineData(-2.71828183f, -2.71828151f)] // value: -(e)
620 [InlineData(-2.30258509f, -2.30258489f)] // value: -(ln(10))
621 [InlineData(-1.57079633f, -1.57079625f)] // value: -(pi / 2)
622 [InlineData(-1.44269504f, -1.44269490f)] // value: -(log2(e))
623 [InlineData(-1.41421356f, -1.41421342f)] // value: -(sqrt(2))
624 [InlineData(-1.12837917f, -1.12837911f)] // value: -(2 / sqrt(pi))
625 [InlineData(-1.0f, -0.999999940f)]
626 [InlineData(-0.785398163f, -0.785398126f)] // value: -(pi / 4)
627 [InlineData(-0.707106781f, -0.707106709f)] // value: -(1 / sqrt(2))
628 [InlineData(-0.693147181f, -0.693147123f)] // value: -(ln(2))
629 [InlineData(-0.636619772f, -0.636619687f)] // value: -(2 / pi)
630 [InlineData(-0.434294482f, -0.434294462f)] // value: -(log10(e))
631 [InlineData(-0.318309886f, -0.318309844f)] // value: -(1 / pi)
632 [InlineData(-0.0f, float.Epsilon)]
633 [InlineData(float.NaN, float.NaN)]
634 [InlineData(0.0f, float.Epsilon)]
635 [InlineData(0.318309886f, 0.318309903f)] // value: (1 / pi)
636 [InlineData(0.434294482f, 0.434294522f)] // value: (log10(e))
637 [InlineData(0.636619772f, 0.636619806f)] // value: (2 / pi)
638 [InlineData(0.693147181f, 0.693147242f)] // value: (ln(2))
639 [InlineData(0.707106781f, 0.707106829f)] // value: (1 / sqrt(2))
640 [InlineData(0.785398163f, 0.785398245f)] // value: (pi / 4)
641 [InlineData(1.0f, 1.00000012f)]
642 [InlineData(1.12837917f, 1.12837934f)] // value: (2 / sqrt(pi))
643 [InlineData(1.41421356f, 1.41421366f)] // value: (sqrt(2))
644 [InlineData(1.44269504f, 1.44269514f)] // value: (log2(e))
645 [InlineData(1.57079633f, 1.57079649f)] // value: (pi / 2)
646 [InlineData(2.30258509f, 2.30258536f)] // value: (ln(10))
647 [InlineData(2.71828183f, 2.71828198f)] // value: (e)
648 [InlineData(3.14159265f, 3.14159298f)] // value: (pi)
649 [InlineData(float.PositiveInfinity, float.PositiveInfinity)]
650 public static void BitIncrement(float value, float expectedResult)
652 AssertEqual(expectedResult, MathF.BitIncrement(value), 0.0f);
656 [InlineData(float.NegativeInfinity, float.NegativeInfinity, 0.0f)]
657 [InlineData(-3.14159265f, -1.46459189f, CrossPlatformMachineEpsilon * 10)] // value: -(pi)
658 [InlineData(-2.71828183f, -1.39561243f, CrossPlatformMachineEpsilon * 10)] // value: -(e)
659 [InlineData(-2.30258509f, -1.32050048f, CrossPlatformMachineEpsilon * 10)] // value: -(ln(10))
660 [InlineData(-1.57079633f, -1.16244735f, CrossPlatformMachineEpsilon * 10)] // value: -(pi / 2)
661 [InlineData(-1.44269504f, -1.12994728f, CrossPlatformMachineEpsilon * 10)] // value: -(log2(e))
662 [InlineData(-1.41421356f, -1.12246205f, CrossPlatformMachineEpsilon * 10)] // value: -(sqrt(2))
663 [InlineData(-1.12837917f, -1.04108220f, CrossPlatformMachineEpsilon * 10)] // value: -(2 / sqrt(pi))
664 [InlineData(-1.0f, -1.0f, CrossPlatformMachineEpsilon * 10)]
665 [InlineData(-0.785398163f, -0.922635074f, CrossPlatformMachineEpsilon)] // value: -(pi / 4)
666 [InlineData(-0.707106781f, -0.890898718f, CrossPlatformMachineEpsilon)] // value: -(1 / sqrt(2))
667 [InlineData(-0.693147181f, -0.884997045f, CrossPlatformMachineEpsilon)] // value: -(ln(2))
668 [InlineData(-0.636619772f, -0.860254014f, CrossPlatformMachineEpsilon)] // value: -(2 / pi)
669 [InlineData(-0.434294482f, -0.757288631f, CrossPlatformMachineEpsilon)] // value: -(log10(e))
670 [InlineData(-0.318309886f, -0.682784063f, CrossPlatformMachineEpsilon)] // value: -(1 / pi)
671 [InlineData(-0.0f, -0.0f, 0.0f)]
672 [InlineData(float.NaN, float.NaN, 0.0f)]
673 [InlineData(0.0f, 0.0f, 0.0f)]
674 [InlineData(0.318309886f, 0.682784063f, CrossPlatformMachineEpsilon)] // value: (1 / pi)
675 [InlineData(0.434294482f, 0.757288631f, CrossPlatformMachineEpsilon)] // value: (log10(e))
676 [InlineData(0.636619772f, 0.860254014f, CrossPlatformMachineEpsilon)] // value: (2 / pi)
677 [InlineData(0.693147181f, 0.884997045f, CrossPlatformMachineEpsilon)] // value: (ln(2))
678 [InlineData(0.707106781f, 0.890898718f, CrossPlatformMachineEpsilon)] // value: (1 / sqrt(2))
679 [InlineData(0.785398163f, 0.922635074f, CrossPlatformMachineEpsilon)] // value: (pi / 4)
680 [InlineData(1.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
681 [InlineData(1.12837917f, 1.04108220f, CrossPlatformMachineEpsilon * 10)] // value: (2 / sqrt(pi))
682 [InlineData(1.41421356f, 1.12246205f, CrossPlatformMachineEpsilon * 10)] // value: (sqrt(2))
683 [InlineData(1.44269504f, 1.12994728f, CrossPlatformMachineEpsilon * 10)] // value: (log2(e))
684 [InlineData(1.57079633f, 1.16244735f, CrossPlatformMachineEpsilon * 10)] // value: (pi / 2)
685 [InlineData(2.30258509f, 1.32050048f, CrossPlatformMachineEpsilon * 10)] // value: (ln(10))
686 [InlineData(2.71828183f, 1.39561243f, CrossPlatformMachineEpsilon * 10)] // value: (e)
687 [InlineData(3.14159265f, 1.46459189f, CrossPlatformMachineEpsilon * 10)] // value: (pi)
688 [InlineData(float.PositiveInfinity, float.PositiveInfinity, 0.0f)]
689 public static void Cbrt(float value, float expectedResult, float allowedVariance)
691 AssertEqual(expectedResult, MathF.Cbrt(value), allowedVariance);
695 [InlineData(float.NegativeInfinity, float.NegativeInfinity, 0.0f)]
696 [InlineData(-3.14159265f, -3.0f, 0.0f)] // value: -(pi)
697 [InlineData(-2.71828183f, -2.0f, 0.0f)] // value: -(e)
698 [InlineData(-2.30258509f, -2.0f, 0.0f)] // value: -(ln(10))
699 [InlineData(-1.57079633f, -1.0f, 0.0f)] // value: -(pi / 2)
700 [InlineData(-1.44269504f, -1.0f, 0.0f)] // value: -(log2(e))
701 [InlineData(-1.41421356f, -1.0f, 0.0f)] // value: -(sqrt(2))
702 [InlineData(-1.12837917f, -1.0f, 0.0f)] // value: -(2 / sqrt(pi))
703 [InlineData(-1.0f, -1.0f, 0.0f)]
704 [InlineData(-0.785398163f, -0.0f, 0.0f)] // value: -(pi / 4)
705 [InlineData(-0.707106781f, -0.0f, 0.0f)] // value: -(1 / sqrt(2))
706 [InlineData(-0.693147181f, -0.0f, 0.0f)] // value: -(ln(2))
707 [InlineData(-0.636619772f, -0.0f, 0.0f)] // value: -(2 / pi)
708 [InlineData(-0.434294482f, -0.0f, 0.0f)] // value: -(log10(e))
709 [InlineData(-0.318309886f, -0.0f, 0.0f)] // value: -(1 / pi)
710 [InlineData(-0.0f, -0.0f, 0.0f)]
711 [InlineData(float.NaN, float.NaN, 0.0f)]
712 [InlineData(0.0f, 0.0f, 0.0f)]
713 [InlineData(0.318309886f, 1.0f, 0.0f)] // value: (1 / pi)
714 [InlineData(0.434294482f, 1.0f, 0.0f)] // value: (log10(e))
715 [InlineData(0.636619772f, 1.0f, 0.0f)] // value: (2 / pi)
716 [InlineData(0.693147181f, 1.0f, 0.0f)] // value: (ln(2))
717 [InlineData(0.707106781f, 1.0f, 0.0f)] // value: (1 / sqrt(2))
718 [InlineData(0.785398163f, 1.0f, 0.0f)] // value: (pi / 4)
719 [InlineData(1.0f, 1.0f, 0.0f)]
720 [InlineData(1.12837917f, 2.0f, 0.0f)] // value: (2 / sqrt(pi))
721 [InlineData(1.41421356f, 2.0f, 0.0f)] // value: (sqrt(2))
722 [InlineData(1.44269504f, 2.0f, 0.0f)] // value: (log2(e))
723 [InlineData(1.57079633f, 2.0f, 0.0f)] // value: (pi / 2)
724 [InlineData(2.30258509f, 3.0f, 0.0f)] // value: (ln(10))
725 [InlineData(2.71828183f, 3.0f, 0.0f)] // value: (e)
726 [InlineData(3.14159265f, 4.0f, 0.0f)] // value: (pi)
727 [InlineData(float.PositiveInfinity, float.PositiveInfinity, 0.0f)]
728 public static void Ceiling(float value, float expectedResult, float allowedVariance)
730 AssertEqual(expectedResult, MathF.Ceiling(value), allowedVariance);
734 [InlineData(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity)]
735 [InlineData(float.NegativeInfinity, -3.14159265f, float.NegativeInfinity)]
736 [InlineData(float.NegativeInfinity, -0.0f, float.NegativeInfinity)]
737 [InlineData(float.NegativeInfinity, float.NaN, float.NegativeInfinity)]
738 [InlineData(float.NegativeInfinity, 0.0f, float.PositiveInfinity)]
739 [InlineData(float.NegativeInfinity, 3.14159265f, float.PositiveInfinity)]
740 [InlineData(float.NegativeInfinity, float.PositiveInfinity, float.PositiveInfinity)]
741 [InlineData(-3.14159265f, float.NegativeInfinity, -3.14159265f)]
742 [InlineData(-3.14159265f, -3.14159265f, -3.14159265f)]
743 [InlineData(-3.14159265f, -0.0f, -3.14159265f)]
744 [InlineData(-3.14159265f, float.NaN, -3.14159265f)]
745 [InlineData(-3.14159265f, 0.0f, 3.14159265f)]
746 [InlineData(-3.14159265f, 3.14159265f, 3.14159265f)]
747 [InlineData(-3.14159265f, float.PositiveInfinity, 3.14159265f)]
748 [InlineData(-0.0f, float.NegativeInfinity, -0.0f)]
749 [InlineData(-0.0f, -3.14159265f, -0.0f)]
750 [InlineData(-0.0f, -0.0f, -0.0f)]
751 [InlineData(-0.0f, float.NaN, -0.0f)]
752 [InlineData(-0.0f, 0.0f, 0.0f)]
753 [InlineData(-0.0f, 3.14159265f, 0.0f)]
754 [InlineData(-0.0f, float.PositiveInfinity, 0.0f)]
755 [InlineData(float.NaN, float.NegativeInfinity, float.NaN)]
756 [InlineData(float.NaN, -3.14159265f, float.NaN)]
757 [InlineData(float.NaN, -0.0f, float.NaN)]
758 [InlineData(float.NaN, float.NaN, float.NaN)]
759 [InlineData(float.NaN, 0.0f, float.NaN)]
760 [InlineData(float.NaN, 3.14159265f, float.NaN)]
761 [InlineData(float.NaN, float.PositiveInfinity, float.NaN)]
762 [InlineData(0.0f, float.NegativeInfinity, -0.0f)]
763 [InlineData(0.0f, -3.14159265f, -0.0f)]
764 [InlineData(0.0f, -0.0f, -0.0f)]
765 [InlineData(0.0f, float.NaN, -0.0f)]
766 [InlineData(0.0f, 0.0f, 0.0f)]
767 [InlineData(0.0f, 3.14159265f, 0.0f)]
768 [InlineData(0.0f, float.PositiveInfinity, 0.0f)]
769 [InlineData(3.14159265f, float.NegativeInfinity, -3.14159265f)]
770 [InlineData(3.14159265f, -3.14159265f, -3.14159265f)]
771 [InlineData(3.14159265f, -0.0f, -3.14159265f)]
772 [InlineData(3.14159265f, float.NaN, -3.14159265f)]
773 [InlineData(3.14159265f, 0.0f, 3.14159265f)]
774 [InlineData(3.14159265f, 3.14159265f, 3.14159265f)]
775 [InlineData(3.14159265f, float.PositiveInfinity, 3.14159265f)]
776 [InlineData(float.PositiveInfinity, float.NegativeInfinity, float.NegativeInfinity)]
777 [InlineData(float.PositiveInfinity, -3.14159265f, float.NegativeInfinity)]
778 [InlineData(float.PositiveInfinity, -0.0f, float.NegativeInfinity)]
779 [InlineData(float.PositiveInfinity, float.NaN, float.NegativeInfinity)]
780 [InlineData(float.PositiveInfinity, 0.0f, float.PositiveInfinity)]
781 [InlineData(float.PositiveInfinity, 3.14159265f, float.PositiveInfinity)]
782 [InlineData(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity)]
783 public static void CopySign(float x, float y, float expectedResult)
785 AssertEqual(expectedResult, MathF.CopySign(x, y), 0.0f);
789 [InlineData(float.NegativeInfinity, float.NaN, 0.0f)]
790 [InlineData(-3.14159265f, -1.0f, CrossPlatformMachineEpsilon * 10)] // value: -(pi)
791 [InlineData(-2.71828183f, -0.911733918f, CrossPlatformMachineEpsilon)] // value: -(e)
792 [InlineData(-2.30258509f, -0.668201510f, CrossPlatformMachineEpsilon)] // value: -(ln(10))
793 [InlineData(-1.57079633f, 0.0f, CrossPlatformMachineEpsilon)] // value: -(pi / 2)
794 [InlineData(-1.44269504f, 0.127751218f, CrossPlatformMachineEpsilon)] // value: -(log2(e))
795 [InlineData(-1.41421356f, 0.155943695f, CrossPlatformMachineEpsilon)] // value: -(sqrt(2))
796 [InlineData(-1.12837917f, 0.428125148f, CrossPlatformMachineEpsilon)] // value: -(2 / sqrt(pi))
797 [InlineData(-1.0f, 0.540302306f, CrossPlatformMachineEpsilon)]
798 [InlineData(-0.785398163f, 0.707106781f, CrossPlatformMachineEpsilon)] // value: -(pi / 4), expected: (1 / sqrt(2))
799 [InlineData(-0.707106781f, 0.760244597f, CrossPlatformMachineEpsilon)] // value: -(1 / sqrt(2))
800 [InlineData(-0.693147181f, 0.769238901f, CrossPlatformMachineEpsilon)] // value: -(ln(2))
801 [InlineData(-0.636619772f, 0.804109828f, CrossPlatformMachineEpsilon)] // value: -(2 / pi)
802 [InlineData(-0.434294482f, 0.907167129f, CrossPlatformMachineEpsilon)] // value: -(log10(e))
803 [InlineData(-0.318309886f, 0.949765715f, CrossPlatformMachineEpsilon)] // value: -(1 / pi)
804 [InlineData(-0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
805 [InlineData(float.NaN, float.NaN, 0.0f)]
806 [InlineData(0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
807 [InlineData(0.318309886f, 0.949765715f, CrossPlatformMachineEpsilon)] // value: (1 / pi)
808 [InlineData(0.434294482f, 0.907167129f, CrossPlatformMachineEpsilon)] // value: (log10(e))
809 [InlineData(0.636619772f, 0.804109828f, CrossPlatformMachineEpsilon)] // value: (2 / pi)
810 [InlineData(0.693147181f, 0.769238901f, CrossPlatformMachineEpsilon)] // value: (ln(2))
811 [InlineData(0.707106781f, 0.760244597f, CrossPlatformMachineEpsilon)] // value: (1 / sqrt(2))
812 [InlineData(0.785398163f, 0.707106781f, CrossPlatformMachineEpsilon)] // value: (pi / 4), expected: (1 / sqrt(2))
813 [InlineData(1.0f, 0.540302306f, CrossPlatformMachineEpsilon)]
814 [InlineData(1.12837917f, 0.428125148f, CrossPlatformMachineEpsilon)] // value: (2 / sqrt(pi))
815 [InlineData(1.41421356f, 0.155943695f, CrossPlatformMachineEpsilon)] // value: (sqrt(2))
816 [InlineData(1.44269504f, 0.127751218f, CrossPlatformMachineEpsilon)] // value: (log2(e))
817 [InlineData(1.57079633f, 0.0f, CrossPlatformMachineEpsilon)] // value: (pi / 2)
818 [InlineData(2.30258509f, -0.668201510f, CrossPlatformMachineEpsilon)] // value: (ln(10))
819 [InlineData(2.71828183f, -0.911733918f, CrossPlatformMachineEpsilon)] // value: (e)
820 [InlineData(3.14159265f, -1.0f, CrossPlatformMachineEpsilon * 10)] // value: (pi)
821 [InlineData(float.PositiveInfinity, float.NaN, 0.0f)]
822 public static void Cos(float value, float expectedResult, float allowedVariance)
824 AssertEqual(expectedResult, MathF.Cos(value), allowedVariance);
828 [InlineData(float.NegativeInfinity, float.PositiveInfinity, 0.0f)]
829 [InlineData(-3.14159265f, 11.5919533f, CrossPlatformMachineEpsilon * 100)] // value: (pi)
830 [InlineData(-2.71828183f, 7.61012514f, CrossPlatformMachineEpsilon * 10)] // value: (e)
831 [InlineData(-2.30258509f, 5.05f, CrossPlatformMachineEpsilon * 10)] // value: (ln(10))
832 [InlineData(-1.57079633f, 2.50917848f, CrossPlatformMachineEpsilon * 10)] // value: (pi / 2)
833 [InlineData(-1.44269504f, 2.23418810f, CrossPlatformMachineEpsilon * 10)] // value: (log2(e))
834 [InlineData(-1.41421356f, 2.17818356f, CrossPlatformMachineEpsilon * 10)] // value: (sqrt(2))
835 [InlineData(-1.12837917f, 1.70710014f, CrossPlatformMachineEpsilon * 10)] // value: (2 / sqrt(pi))
836 [InlineData(-1.0f, 1.54308063f, CrossPlatformMachineEpsilon * 10)]
837 [InlineData(-0.785398163f, 1.32460909f, CrossPlatformMachineEpsilon * 10)] // value: (pi / 4)
838 [InlineData(-0.707106781f, 1.26059184f, CrossPlatformMachineEpsilon * 10)] // value: (1 / sqrt(2))
839 [InlineData(-0.693147181f, 1.25f, CrossPlatformMachineEpsilon * 10)] // value: (ln(2))
840 [InlineData(-0.636619772f, 1.20957949f, CrossPlatformMachineEpsilon * 10)] // value: (2 / pi)
841 [InlineData(-0.434294482f, 1.09579746f, CrossPlatformMachineEpsilon * 10)] // value: (log10(e))
842 [InlineData(-0.318309886f, 1.05108979f, CrossPlatformMachineEpsilon * 10)] // value: (1 / pi)
843 [InlineData(-0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
844 [InlineData(float.NaN, float.NaN, 0.0f)]
845 [InlineData(0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
846 [InlineData(0.318309886f, 1.05108979f, CrossPlatformMachineEpsilon * 10)] // value: (1 / pi)
847 [InlineData(0.434294482f, 1.09579746f, CrossPlatformMachineEpsilon * 10)] // value: (log10(e))
848 [InlineData(0.636619772f, 1.20957949f, CrossPlatformMachineEpsilon * 10)] // value: (2 / pi)
849 [InlineData(0.693147181f, 1.25f, CrossPlatformMachineEpsilon * 10)] // value: (ln(2))
850 [InlineData(0.707106781f, 1.26059184f, CrossPlatformMachineEpsilon * 10)] // value: (1 / sqrt(2))
851 [InlineData(0.785398163f, 1.32460909f, CrossPlatformMachineEpsilon * 10)] // value: (pi / 4)
852 [InlineData(1.0f, 1.54308063f, CrossPlatformMachineEpsilon * 10)]
853 [InlineData(1.12837917f, 1.70710014f, CrossPlatformMachineEpsilon * 10)] // value: (2 / sqrt(pi))
854 [InlineData(1.41421356f, 2.17818356f, CrossPlatformMachineEpsilon * 10)] // value: (sqrt(2))
855 [InlineData(1.44269504f, 2.23418810f, CrossPlatformMachineEpsilon * 10)] // value: (log2(e))
856 [InlineData(1.57079633f, 2.50917848f, CrossPlatformMachineEpsilon * 10)] // value: (pi / 2)
857 [InlineData(2.30258509f, 5.05f, CrossPlatformMachineEpsilon * 10)] // value: (ln(10))
858 [InlineData(2.71828183f, 7.61012514f, CrossPlatformMachineEpsilon * 10)] // value: (e)
859 [InlineData(3.14159265f, 11.5919533f, CrossPlatformMachineEpsilon * 100)] // value: (pi)
860 [InlineData(float.PositiveInfinity, float.PositiveInfinity, 0.0f)]
861 public static void Cosh(float value, float expectedResult, float allowedVariance)
863 AssertEqual(expectedResult, MathF.Cosh(value), allowedVariance);
867 [InlineData(float.NegativeInfinity, 0.0f, CrossPlatformMachineEpsilon)]
868 [InlineData(-3.14159265f, 0.0432139183f, CrossPlatformMachineEpsilon / 10)] // value: -(pi)
869 [InlineData(-2.71828183f, 0.0659880358f, CrossPlatformMachineEpsilon / 10)] // value: -(e)
870 [InlineData(-2.30258509f, 0.1f, CrossPlatformMachineEpsilon)] // value: -(ln(10))
871 [InlineData(-1.57079633f, 0.207879576f, CrossPlatformMachineEpsilon)] // value: -(pi / 2)
872 [InlineData(-1.44269504f, 0.236290088f, CrossPlatformMachineEpsilon)] // value: -(log2(e))
873 [InlineData(-1.41421356f, 0.243116734f, CrossPlatformMachineEpsilon)] // value: -(sqrt(2))
874 [InlineData(-1.12837917f, 0.323557264f, CrossPlatformMachineEpsilon)] // value: -(2 / sqrt(pi))
875 [InlineData(-1.0f, 0.367879441f, CrossPlatformMachineEpsilon)]
876 [InlineData(-0.785398163f, 0.455938128f, CrossPlatformMachineEpsilon)] // value: -(pi / 4)
877 [InlineData(-0.707106781f, 0.493068691f, CrossPlatformMachineEpsilon)] // value: -(1 / sqrt(2))
878 [InlineData(-0.693147181f, 0.5f, CrossPlatformMachineEpsilon)] // value: -(ln(2))
879 [InlineData(-0.636619772f, 0.529077808f, CrossPlatformMachineEpsilon)] // value: -(2 / pi)
880 [InlineData(-0.434294482f, 0.647721485f, CrossPlatformMachineEpsilon)] // value: -(log10(e))
881 [InlineData(-0.318309886f, 0.727377349f, CrossPlatformMachineEpsilon)] // value: -(1 / pi)
882 [InlineData(-0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
883 [InlineData(float.NaN, float.NaN, 0.0f)]
884 [InlineData(0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
885 [InlineData(0.318309886f, 1.37480223f, CrossPlatformMachineEpsilon * 10)] // value: (1 / pi)
886 [InlineData(0.434294482f, 1.54387344f, CrossPlatformMachineEpsilon * 10)] // value: (log10(e))
887 [InlineData(0.636619772f, 1.89008116f, CrossPlatformMachineEpsilon * 10)] // value: (2 / pi)
888 [InlineData(0.693147181f, 2.0f, CrossPlatformMachineEpsilon * 10)] // value: (ln(2))
889 [InlineData(0.707106781f, 2.02811498f, CrossPlatformMachineEpsilon * 10)] // value: (1 / sqrt(2))
890 [InlineData(0.785398163f, 2.19328005f, CrossPlatformMachineEpsilon * 10)] // value: (pi / 4)
891 [InlineData(1.0f, 2.71828183f, CrossPlatformMachineEpsilon * 10)] // expected: (e)
892 [InlineData(1.12837917f, 3.09064302f, CrossPlatformMachineEpsilon * 10)] // value: (2 / sqrt(pi))
893 [InlineData(1.41421356f, 4.11325038f, CrossPlatformMachineEpsilon * 10)] // value: (sqrt(2))
894 [InlineData(1.44269504f, 4.23208611f, CrossPlatformMachineEpsilon * 10)] // value: (log2(e))
895 [InlineData(1.57079633f, 4.81047738f, CrossPlatformMachineEpsilon * 10)] // value: (pi / 2)
896 [InlineData(2.30258509f, 10.0f, CrossPlatformMachineEpsilon * 100)] // value: (ln(10))
897 [InlineData(2.71828183f, 15.1542622f, CrossPlatformMachineEpsilon * 100)] // value: (e)
898 [InlineData(3.14159265f, 23.1406926f, CrossPlatformMachineEpsilon * 100)] // value: (pi)
899 [InlineData(float.PositiveInfinity, float.PositiveInfinity, 0.0f)]
900 public static void Exp(float value, float expectedResult, float allowedVariance)
902 AssertEqual(expectedResult, MathF.Exp(value), allowedVariance);
906 [InlineData(float.NegativeInfinity, float.NegativeInfinity, 0.0f)]
907 [InlineData(-3.14159265f, -4.0f, 0.0f)] // value: -(pi)
908 [InlineData(-2.71828183f, -3.0f, 0.0f)] // value: -(e)
909 [InlineData(-2.30258509f, -3.0f, 0.0f)] // value: -(ln(10))
910 [InlineData(-1.57079633f, -2.0f, 0.0f)] // value: -(pi / 2)
911 [InlineData(-1.44269504f, -2.0f, 0.0f)] // value: -(log2(e))
912 [InlineData(-1.41421356f, -2.0f, 0.0f)] // value: -(sqrt(2))
913 [InlineData(-1.12837917f, -2.0f, 0.0f)] // value: -(2 / sqrt(pi))
914 [InlineData(-1.0f, -1.0f, 0.0f)]
915 [InlineData(-0.785398163f, -1.0f, 0.0f)] // value: -(pi / 4)
916 [InlineData(-0.707106781f, -1.0f, 0.0f)] // value: -(1 / sqrt(2))
917 [InlineData(-0.693147181f, -1.0f, 0.0f)] // value: -(ln(2))
918 [InlineData(-0.636619772f, -1.0f, 0.0f)] // value: -(2 / pi)
919 [InlineData(-0.434294482f, -1.0f, 0.0f)] // value: -(log10(e))
920 [InlineData(-0.318309886f, -1.0f, 0.0f)] // value: -(1 / pi)
921 [InlineData(-0.0f, -0.0f, 0.0f)]
922 [InlineData(float.NaN, float.NaN, 0.0f)]
923 [InlineData(0.0f, 0.0f, 0.0f)]
924 [InlineData(0.318309886f, 0.0f, 0.0f)] // value: (1 / pi)
925 [InlineData(0.434294482f, 0.0f, 0.0f)] // value: (log10(e))
926 [InlineData(0.636619772f, 0.0f, 0.0f)] // value: (2 / pi)
927 [InlineData(0.693147181f, 0.0f, 0.0f)] // value: (ln(2))
928 [InlineData(0.707106781f, 0.0f, 0.0f)] // value: (1 / sqrt(2))
929 [InlineData(0.785398163f, 0.0f, 0.0f)] // value: (pi / 4)
930 [InlineData(1.0f, 1.0f, 0.0f)]
931 [InlineData(1.12837917f, 1.0f, 0.0f)] // value: (2 / sqrt(pi))
932 [InlineData(1.41421356f, 1.0f, 0.0f)] // value: (sqrt(2))
933 [InlineData(1.44269504f, 1.0f, 0.0f)] // value: (log2(e))
934 [InlineData(1.57079633f, 1.0f, 0.0f)] // value: (pi / 2)
935 [InlineData(2.30258509f, 2.0f, 0.0f)] // value: (ln(10))
936 [InlineData(2.71828183f, 2.0f, 0.0f)] // value: (e)
937 [InlineData(3.14159265f, 3.0f, 0.0f)] // value: (pi)
938 [InlineData(float.PositiveInfinity, float.PositiveInfinity, 0.0f)]
939 public static void Floor(float value, float expectedResult, float allowedVariance)
941 AssertEqual(expectedResult, MathF.Floor(value), allowedVariance);
945 [InlineData(float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity, float.NaN)]
946 [InlineData(float.NegativeInfinity, -0.0f, float.NegativeInfinity, float.NaN)]
947 [InlineData(float.NegativeInfinity, -0.0f, -3.14159265f, float.NaN)]
948 [InlineData(float.NegativeInfinity, -0.0f, -0.0f, float.NaN)]
949 [InlineData(float.NegativeInfinity, -0.0f, float.NaN, float.NaN)]
950 [InlineData(float.NegativeInfinity, -0.0f, 0.0f, float.NaN)]
951 [InlineData(float.NegativeInfinity, -0.0f, 3.14159265f, float.NaN)]
952 [InlineData(float.NegativeInfinity, -0.0f, float.PositiveInfinity, float.NaN)]
953 [InlineData(float.NegativeInfinity, 0.0f, float.NegativeInfinity, float.NaN)]
954 [InlineData(float.NegativeInfinity, 0.0f, -3.14159265f, float.NaN)]
955 [InlineData(float.NegativeInfinity, 0.0f, -0.0f, float.NaN)]
956 [InlineData(float.NegativeInfinity, 0.0f, float.NaN, float.NaN)]
957 [InlineData(float.NegativeInfinity, 0.0f, 0.0f, float.NaN)]
958 [InlineData(float.NegativeInfinity, 0.0f, 3.14159265f, float.NaN)]
959 [InlineData(float.NegativeInfinity, 0.0f, float.PositiveInfinity, float.NaN)]
960 [InlineData(float.NegativeInfinity, float.PositiveInfinity, float.PositiveInfinity, float.NaN)]
961 [InlineData(-1e38f, 2.0f, 1e38f, -1e38f)]
962 [InlineData(-1e38f, 2.0f, float.PositiveInfinity, float.PositiveInfinity)]
963 [InlineData(-5, 4, -3, -23)]
964 [InlineData(-0.0f, float.NegativeInfinity, float.NegativeInfinity, float.NaN)]
965 [InlineData(-0.0f, float.NegativeInfinity, -3.14159265f, float.NaN)]
966 [InlineData(-0.0f, float.NegativeInfinity, -0.0f, float.NaN)]
967 [InlineData(-0.0f, float.NegativeInfinity, float.NaN, float.NaN)]
968 [InlineData(-0.0f, float.NegativeInfinity, 0.0f, float.NaN)]
969 [InlineData(-0.0f, float.NegativeInfinity, 3.14159265f, float.NaN)]
970 [InlineData(-0.0f, float.NegativeInfinity, float.PositiveInfinity, float.NaN)]
971 [InlineData(-0.0f, float.PositiveInfinity, float.NegativeInfinity, float.NaN)]
972 [InlineData(-0.0f, float.PositiveInfinity, -3.14159265f, float.NaN)]
973 [InlineData(-0.0f, float.PositiveInfinity, -0.0f, float.NaN)]
974 [InlineData(-0.0f, float.PositiveInfinity, float.NaN, float.NaN)]
975 [InlineData(-0.0f, float.PositiveInfinity, 0.0f, float.NaN)]
976 [InlineData(-0.0f, float.PositiveInfinity, 3.14159265f, float.NaN)]
977 [InlineData(-0.0f, float.PositiveInfinity, float.PositiveInfinity, float.NaN)]
978 [InlineData(0.0f, float.NegativeInfinity, float.NegativeInfinity, float.NaN)]
979 [InlineData(0.0f, float.NegativeInfinity, -3.14159265f, float.NaN)]
980 [InlineData(0.0f, float.NegativeInfinity, -0.0f, float.NaN)]
981 [InlineData(0.0f, float.NegativeInfinity, float.NaN, float.NaN)]
982 [InlineData(0.0f, float.NegativeInfinity, 0.0f, float.NaN)]
983 [InlineData(0.0f, float.NegativeInfinity, 3.14159265f, float.NaN)]
984 [InlineData(0.0f, float.NegativeInfinity, float.PositiveInfinity, float.NaN)]
985 [InlineData(0.0f, float.PositiveInfinity, float.NegativeInfinity, float.NaN)]
986 [InlineData(0.0f, float.PositiveInfinity, -3.14159265f, float.NaN)]
987 [InlineData(0.0f, float.PositiveInfinity, -0.0f, float.NaN)]
988 [InlineData(0.0f, float.PositiveInfinity, float.NaN, float.NaN)]
989 [InlineData(0.0f, float.PositiveInfinity, 0.0f, float.NaN)]
990 [InlineData(0.0f, float.PositiveInfinity, 3.14159265f, float.NaN)]
991 [InlineData(0.0f, float.PositiveInfinity, float.PositiveInfinity, float.NaN)]
992 [InlineData(5, 4, 3, 23)]
993 [InlineData(1e38f, 2.0f, -1e38f, 1e38f)]
994 [InlineData(1e38f, 2.0f, float.NegativeInfinity, float.NegativeInfinity)]
995 [InlineData(float.PositiveInfinity, float.NegativeInfinity, float.PositiveInfinity, float.NaN)]
996 [InlineData(float.PositiveInfinity, -0.0f, float.NegativeInfinity, float.NaN)]
997 [InlineData(float.PositiveInfinity, -0.0f, -3.14159265f, float.NaN)]
998 [InlineData(float.PositiveInfinity, -0.0f, -0.0f, float.NaN)]
999 [InlineData(float.PositiveInfinity, -0.0f, float.NaN, float.NaN)]
1000 [InlineData(float.PositiveInfinity, -0.0f, 0.0f, float.NaN)]
1001 [InlineData(float.PositiveInfinity, -0.0f, 3.14159265f, float.NaN)]
1002 [InlineData(float.PositiveInfinity, -0.0f, float.PositiveInfinity, float.NaN)]
1003 [InlineData(float.PositiveInfinity, 0.0f, float.NegativeInfinity, float.NaN)]
1004 [InlineData(float.PositiveInfinity, 0.0f, -3.14159265f, float.NaN)]
1005 [InlineData(float.PositiveInfinity, 0.0f, -0.0f, float.NaN)]
1006 [InlineData(float.PositiveInfinity, 0.0f, float.NaN, float.NaN)]
1007 [InlineData(float.PositiveInfinity, 0.0f, 0.0f, float.NaN)]
1008 [InlineData(float.PositiveInfinity, 0.0f, 3.14159265f, float.NaN)]
1009 [InlineData(float.PositiveInfinity, 0.0f, float.PositiveInfinity, float.NaN)]
1010 [InlineData(float.PositiveInfinity, float.PositiveInfinity, float.NegativeInfinity, float.NaN)]
1011 public static void FusedMultiplyAdd(float x, float y, float z, float expectedResult)
1013 AssertEqual(expectedResult, MathF.FusedMultiplyAdd(x, y, z), 0.0f);
1017 public static void IEEERemainder()
1019 Assert.Equal(-1.0f, MathF.IEEERemainder(3.0f, 2.0f));
1020 Assert.Equal(0.0f, MathF.IEEERemainder(4.0f, 2.0f));
1021 Assert.Equal(1.0f, MathF.IEEERemainder(10.0f, 3.0f));
1022 Assert.Equal(-1.0f, MathF.IEEERemainder(11.0f, 3.0f));
1023 Assert.Equal(-2.0f, MathF.IEEERemainder(28.0f, 5.0f));
1024 AssertEqual(1.8f, MathF.IEEERemainder(17.8f, 4.0f), CrossPlatformMachineEpsilon * 10);
1025 AssertEqual(1.4f, MathF.IEEERemainder(17.8f, 4.1f), CrossPlatformMachineEpsilon * 10);
1026 AssertEqual(0.1000004f, MathF.IEEERemainder(-16.3f, 4.1f), CrossPlatformMachineEpsilon / 10);
1027 AssertEqual(1.4f, MathF.IEEERemainder(17.8f, -4.1f), CrossPlatformMachineEpsilon * 10);
1028 AssertEqual(-1.4f, MathF.IEEERemainder(-17.8f, -4.1f), CrossPlatformMachineEpsilon * 10);
1032 [InlineData(float.NegativeInfinity, unchecked((int)(0x7FFFFFFF)))]
1033 [InlineData(-0.0f, unchecked((int)(0x80000000)))]
1034 [InlineData(float.NaN, unchecked((int)(0x7FFFFFFF)))]
1035 [InlineData(0.0f, unchecked((int)(0x80000000)))]
1036 [InlineData(0.113314732f, -4)]
1037 [InlineData(0.151955223f, -3)]
1038 [InlineData(0.202699566f, -3)]
1039 [InlineData(0.336622537f, -2)]
1040 [InlineData(0.367879441f, -2)]
1041 [InlineData(0.375214227f, -2)]
1042 [InlineData(0.457429347f, -2)]
1043 [InlineData(0.5f, -1)]
1044 [InlineData(0.580191810f, -1)]
1045 [InlineData(0.612547327f, -1)]
1046 [InlineData(0.618503138f, -1)]
1047 [InlineData(0.643218242f, -1)]
1048 [InlineData(0.740055574f, -1)]
1049 [InlineData(0.802008879f, -1)]
1050 [InlineData(1.0f, 0)]
1051 [InlineData(1.24686899f, 0)]
1052 [InlineData(1.35124987f, 0)]
1053 [InlineData(1.55468228f, 0)]
1054 [InlineData(1.61680667f, 0)]
1055 [InlineData(1.63252692f, 0)]
1056 [InlineData(1.72356793f, 0)]
1057 [InlineData(2.0f, 1)]
1058 [InlineData(2.18612996f, 1)]
1059 [InlineData(2.66514414f, 1)]
1060 [InlineData(2.71828183f, 1)]
1061 [InlineData(2.97068642f, 1)]
1062 [InlineData(4.93340967f, 2)]
1063 [InlineData(6.58088599f, 2)]
1064 [InlineData(8.82497783f, 3)]
1065 [InlineData(float.PositiveInfinity, unchecked((int)(0x7FFFFFFF)))]
1066 public static void ILogB(float value, int expectedResult)
1068 Assert.Equal(expectedResult, MathF.ILogB(value));
1072 [InlineData(float.NegativeInfinity, float.NaN, 0.0f)]
1073 [InlineData(-3.14159265f, float.NaN, 0.0f)] // value: -(pi)
1074 [InlineData(-2.71828183f, float.NaN, 0.0f)] // value: -(e)
1075 [InlineData(-1.41421356f, float.NaN, 0.0f)] // value: -(sqrt(2))
1076 [InlineData(-1.0f, float.NaN, 0.0f)]
1077 [InlineData(-0.693147181f, float.NaN, 0.0f)] // value: -(ln(2))
1078 [InlineData(-0.434294482f, float.NaN, 0.0f)] // value: -(log10(e))
1079 [InlineData(-0.0f, float.NegativeInfinity, 0.0f)]
1080 [InlineData(float.NaN, float.NaN, 0.0f)]
1081 [InlineData(0.0f, float.NegativeInfinity, 0.0f)]
1082 [InlineData(0.0432139183f, -3.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi)
1083 [InlineData(0.0659880358f, -2.71828183f, CrossPlatformMachineEpsilon * 10)] // expected: -(e)
1084 [InlineData(0.1f, -2.30258509f, CrossPlatformMachineEpsilon * 10)] // expected: -(ln(10))
1085 [InlineData(0.207879576f, -1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi / 2)
1086 [InlineData(0.236290088f, -1.44269504f, CrossPlatformMachineEpsilon * 10)] // expected: -(log2(e))
1087 [InlineData(0.243116734f, -1.41421356f, CrossPlatformMachineEpsilon * 10)] // expected: -(sqrt(2))
1088 [InlineData(0.323557264f, -1.12837917f, CrossPlatformMachineEpsilon * 10)] // expected: -(2 / sqrt(pi))
1089 [InlineData(0.367879441f, -1.0f, CrossPlatformMachineEpsilon * 10)]
1090 [InlineData(0.455938128f, -0.785398163f, CrossPlatformMachineEpsilon)] // expected: -(pi / 4)
1091 [InlineData(0.493068691f, -0.707106781f, CrossPlatformMachineEpsilon)] // expected: -(1 / sqrt(2))
1092 [InlineData(0.5f, -0.693147181f, CrossPlatformMachineEpsilon)] // expected: -(ln(2))
1093 [InlineData(0.529077808f, -0.636619772f, CrossPlatformMachineEpsilon)] // expected: -(2 / pi)
1094 [InlineData(0.647721485f, -0.434294482f, CrossPlatformMachineEpsilon)] // expected: -(log10(e))
1095 [InlineData(0.727377349f, -0.318309886f, CrossPlatformMachineEpsilon)] // expected: -(1 / pi)
1096 [InlineData(1.0f, 0.0f, 0.0f)]
1097 [InlineData(1.37480223f, 0.318309886f, CrossPlatformMachineEpsilon)] // expected: (1 / pi)
1098 [InlineData(1.54387344f, 0.434294482f, CrossPlatformMachineEpsilon)] // expected: (log10(e))
1099 [InlineData(1.89008116f, 0.636619772f, CrossPlatformMachineEpsilon)] // expected: (2 / pi)
1100 [InlineData(2.0f, 0.693147181f, CrossPlatformMachineEpsilon)] // expected: (ln(2))
1101 [InlineData(2.02811498f, 0.707106781f, CrossPlatformMachineEpsilon)] // expected: (1 / sqrt(2))
1102 [InlineData(2.19328005f, 0.785398163f, CrossPlatformMachineEpsilon)] // expected: (pi / 4)
1103 [InlineData(2.71828183f, 1.0f, CrossPlatformMachineEpsilon * 10)] // value: (e)
1104 [InlineData(3.09064302f, 1.12837917f, CrossPlatformMachineEpsilon * 10)] // expected: (2 / sqrt(pi))
1105 [InlineData(4.11325038f, 1.41421356f, CrossPlatformMachineEpsilon * 10)] // expected: (sqrt(2))
1106 [InlineData(4.23208611f, 1.44269504f, CrossPlatformMachineEpsilon * 10)] // expected: (log2(e))
1107 [InlineData(4.81047738f, 1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: (pi / 2)
1108 [InlineData(10.0f, 2.30258509f, CrossPlatformMachineEpsilon * 10)] // expected: (ln(10))
1109 [InlineData(15.1542622f, 2.71828183f, CrossPlatformMachineEpsilon * 10)] // expected: (e)
1110 [InlineData(23.1406926f, 3.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: (pi)
1111 [InlineData(float.PositiveInfinity, float.PositiveInfinity, 0.0f)]
1112 public static void Log(float value, float expectedResult, float allowedVariance)
1114 AssertEqual(expectedResult, MathF.Log(value), allowedVariance);
1118 public static void LogWithBase()
1120 Assert.Equal(1.0f, MathF.Log(3.0f, 3.0f));
1121 AssertEqual(2.40217350f, MathF.Log(14.0f, 3.0f), CrossPlatformMachineEpsilon * 10);
1122 Assert.Equal(float.NegativeInfinity, MathF.Log(0.0f, 3.0f));
1123 Assert.Equal(float.NaN, MathF.Log(-3.0f, 3.0f));
1124 Assert.Equal(float.NaN, MathF.Log(float.NaN, 3.0f));
1125 Assert.Equal(float.PositiveInfinity, MathF.Log(float.PositiveInfinity, 3.0f));
1126 Assert.Equal(float.NaN, MathF.Log(float.NegativeInfinity, 3.0f));
1130 [InlineData(float.NegativeInfinity, float.NaN, 0.0f)]
1131 [InlineData(-0.113314732f, float.NaN, 0.0f)]
1132 [InlineData(-0.0f, float.NegativeInfinity, 0.0f)]
1133 [InlineData(float.NaN, float.NaN, 0.0f)]
1134 [InlineData(0.0f, float.NegativeInfinity, 0.0f)]
1135 [InlineData(0.113314732f, -3.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi)
1136 [InlineData(0.151955223f, -2.71828183f, CrossPlatformMachineEpsilon * 10)] // expected: -(e)
1137 [InlineData(0.202699566f, -2.30258509f, CrossPlatformMachineEpsilon * 10)] // expected: -(ln(10))
1138 [InlineData(0.336622537f, -1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi / 2)
1139 [InlineData(0.367879441f, -1.44269504f, CrossPlatformMachineEpsilon * 10)] // expected: -(log2(e))
1140 [InlineData(0.375214227f, -1.41421356f, CrossPlatformMachineEpsilon * 10)] // expected: -(sqrt(2))
1141 [InlineData(0.457429347f, -1.12837917f, CrossPlatformMachineEpsilon * 10)] // expected: -(2 / sqrt(pi))
1142 [InlineData(0.5f, -1.0f, CrossPlatformMachineEpsilon * 10)]
1143 [InlineData(0.580191810f, -0.785398163f, CrossPlatformMachineEpsilon)] // expected: -(pi / 4)
1144 [InlineData(0.612547327f, -0.707106781f, CrossPlatformMachineEpsilon)] // expected: -(1 / sqrt(2))
1145 [InlineData(0.618503138f, -0.693147181f, CrossPlatformMachineEpsilon)] // expected: -(ln(2))
1146 [InlineData(0.643218242f, -0.636619772f, CrossPlatformMachineEpsilon)] // expected: -(2 / pi)
1147 [InlineData(0.740055574f, -0.434294482f, CrossPlatformMachineEpsilon)] // expected: -(log10(e))
1148 [InlineData(0.802008879f, -0.318309886f, CrossPlatformMachineEpsilon)] // expected: -(1 / pi)
1149 [InlineData(1, 0.0f, 0.0f)]
1150 [InlineData(1.24686899f, 0.318309886f, CrossPlatformMachineEpsilon)] // expected: (1 / pi)
1151 [InlineData(1.35124987f, 0.434294482f, CrossPlatformMachineEpsilon)] // expected: (log10(e))
1152 [InlineData(1.55468228f, 0.636619772f, CrossPlatformMachineEpsilon)] // expected: (2 / pi)
1153 [InlineData(1.61680667f, 0.693147181f, CrossPlatformMachineEpsilon)] // expected: (ln(2))
1154 [InlineData(1.63252692f, 0.707106781f, CrossPlatformMachineEpsilon)] // expected: (1 / sqrt(2))
1155 [InlineData(1.72356793f, 0.785398163f, CrossPlatformMachineEpsilon)] // expected: (pi / 4)
1156 [InlineData(2, 1.0f, CrossPlatformMachineEpsilon * 10)] // value: (e)
1157 [InlineData(2.18612996f, 1.12837917f, CrossPlatformMachineEpsilon * 10)] // expected: (2 / sqrt(pi))
1158 [InlineData(2.66514414f, 1.41421356f, CrossPlatformMachineEpsilon * 10)] // expected: (sqrt(2))
1159 [InlineData(2.71828183f, 1.44269504f, CrossPlatformMachineEpsilon * 10)] // expected: (log2(e))
1160 [InlineData(2.97068642f, 1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: (pi / 2)
1161 [InlineData(4.93340967f, 2.30258509f, CrossPlatformMachineEpsilon * 10)] // expected: (ln(10))
1162 [InlineData(6.58088599f, 2.71828183f, CrossPlatformMachineEpsilon * 10)] // expected: (e)
1163 [InlineData(8.82497783f, 3.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: (pi)
1164 [InlineData(float.PositiveInfinity, float.PositiveInfinity, 0.0f)]
1165 public static void Log2(float value, float expectedResult, float allowedVariance)
1167 AssertEqual(expectedResult, MathF.Log2(value), allowedVariance);
1171 [InlineData(float.NegativeInfinity, float.NaN, 0.0f)]
1172 [InlineData(-3.14159265f, float.NaN, 0.0f)] // value: -(pi)
1173 [InlineData(-2.71828183f, float.NaN, 0.0f)] // value: -(e)
1174 [InlineData(-1.41421356f, float.NaN, 0.0f)] // value: -(sqrt(2))
1175 [InlineData(-1.0f, float.NaN, 0.0f)]
1176 [InlineData(-0.693147181f, float.NaN, 0.0f)] // value: -(ln(2))
1177 [InlineData(-0.434294482f, float.NaN, 0.0f)] // value: -(log10(e))
1178 [InlineData(-0.0f, float.NegativeInfinity, 0.0f)]
1179 [InlineData(float.NaN, float.NaN, 0.0f)]
1180 [InlineData(0.0f, float.NegativeInfinity, 0.0f)]
1181 [InlineData(0.000721784159f, -3.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi)
1182 [InlineData(0.00191301410f, -2.71828183f, CrossPlatformMachineEpsilon * 10)] // expected: -(e)
1183 [InlineData(0.00498212830f, -2.30258509f, CrossPlatformMachineEpsilon * 10)] // expected: -(ln(10))
1184 [InlineData(0.0268660410f, -1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: -(pi / 2)
1185 [InlineData(0.0360831928f, -1.44269504f, CrossPlatformMachineEpsilon * 10)] // expected: -(log2(e))
1186 [InlineData(0.0385288847f, -1.41421356f, CrossPlatformMachineEpsilon * 10)] // expected: -(sqrt(2))
1187 [InlineData(0.0744082059f, -1.12837917f, CrossPlatformMachineEpsilon * 10)] // expected: -(2 / sqrt(pi))
1188 [InlineData(0.1f, -1.0f, CrossPlatformMachineEpsilon * 10)]
1189 [InlineData(0.163908636f, -0.785398163f, CrossPlatformMachineEpsilon)] // expected: -(pi / 4)
1190 [InlineData(0.196287760f, -0.707106781f, CrossPlatformMachineEpsilon)] // expected: -(1 / sqrt(2))
1191 [InlineData(0.202699566f, -0.693147181f, CrossPlatformMachineEpsilon)] // expected: -(ln(2))
1192 [InlineData(0.230876765f, -0.636619772f, CrossPlatformMachineEpsilon)] // expected: -(2 / pi)
1193 [InlineData(0.367879441f, -0.434294482f, CrossPlatformMachineEpsilon)] // expected: -(log10(e))
1194 [InlineData(0.480496373f, -0.318309886f, CrossPlatformMachineEpsilon)] // expected: -(1 / pi)
1195 [InlineData(1.0f, 0.0f, 0.0f)]
1196 [InlineData(2.08118116f, 0.318309886f, CrossPlatformMachineEpsilon)] // expected: (1 / pi)
1197 [InlineData(2.71828183f, 0.434294482f, CrossPlatformMachineEpsilon)] // expected: (log10(e)) value: (e)
1198 [InlineData(4.33131503f, 0.636619772f, CrossPlatformMachineEpsilon)] // expected: (2 / pi)
1199 [InlineData(4.93340967f, 0.693147181f, CrossPlatformMachineEpsilon)] // expected: (ln(2))
1200 [InlineData(5.09456117f, 0.707106781f, CrossPlatformMachineEpsilon)] // expected: (1 / sqrt(2))
1201 [InlineData(6.10095980f, 0.785398163f, CrossPlatformMachineEpsilon)] // expected: (pi / 4)
1202 [InlineData(10.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1203 [InlineData(13.4393779f, 1.12837917f, CrossPlatformMachineEpsilon * 10)] // expected: (2 / sqrt(pi))
1204 [InlineData(25.9545535f, 1.41421356f, CrossPlatformMachineEpsilon * 10)] // expected: (sqrt(2))
1205 [InlineData(27.7137338f, 1.44269504f, CrossPlatformMachineEpsilon * 10)] // expected: (log2(e))
1206 [InlineData(37.2217105f, 1.57079633f, CrossPlatformMachineEpsilon * 10)] // expected: (pi / 2)
1207 [InlineData(200.717432f, 2.30258509f, CrossPlatformMachineEpsilon * 10)] // expected: (ln(10))
1208 [InlineData(522.735300f, 2.71828183f, CrossPlatformMachineEpsilon * 10)] // expected: (e)
1209 [InlineData(1385.45573f, 3.14159265f, CrossPlatformMachineEpsilon * 10)] // expected: (pi)
1210 [InlineData(float.PositiveInfinity, float.PositiveInfinity, 0.0f)]
1211 public static void Log10(float value, float expectedResult, float allowedVariance)
1213 AssertEqual(expectedResult, MathF.Log10(value), allowedVariance);
1217 [InlineData(float.NegativeInfinity, float.PositiveInfinity, float.PositiveInfinity)]
1218 [InlineData(float.MinValue, float.MaxValue, float.MaxValue)]
1219 [InlineData(float.NaN, float.NaN, float.NaN)]
1220 [InlineData(-0.0f, 0.0f, 0.0f)]
1221 [InlineData(2.0f, -3.0f, 2.0f)]
1222 [InlineData(3.0f, -2.0f, 3.0f)]
1223 [InlineData(float.PositiveInfinity, float.NaN, float.NaN)]
1224 public static void Max(float x, float y, float expectedResult)
1226 AssertEqual(expectedResult, MathF.Max(x, y), 0.0f);
1230 [InlineData(float.NegativeInfinity, float.PositiveInfinity, float.PositiveInfinity)]
1231 [InlineData(float.MinValue, float.MaxValue, float.MaxValue)]
1232 [InlineData(float.NaN, float.NaN, float.NaN)]
1233 [InlineData(-0.0f, 0.0f, 0.0f)]
1234 [InlineData(2.0f, -3.0f, -3.0f)]
1235 [InlineData(3.0f, -2.0f, 3.0f)]
1236 [InlineData(float.PositiveInfinity, float.NaN, float.NaN)]
1237 public static void MaxMagnitude(float x, float y, float expectedResult)
1239 AssertEqual(expectedResult, MathF.MaxMagnitude(x, y), 0.0f);
1243 [InlineData(float.NegativeInfinity, float.PositiveInfinity, float.NegativeInfinity)]
1244 [InlineData(float.MinValue, float.MaxValue, float.MinValue)]
1245 [InlineData(float.NaN, float.NaN, float.NaN)]
1246 [InlineData(-0.0f, 0.0f, -0.0f)]
1247 [InlineData(2.0f, -3.0f, -3.0f)]
1248 [InlineData(3.0f, -2.0f, -2.0f)]
1249 [InlineData(float.PositiveInfinity, float.NaN, float.NaN)]
1250 public static void Min(float x, float y, float expectedResult)
1252 AssertEqual(expectedResult, MathF.Min(x, y), 0.0f);
1256 [InlineData(float.NegativeInfinity, float.PositiveInfinity, float.NegativeInfinity)]
1257 [InlineData(float.MinValue, float.MaxValue, float.MinValue)]
1258 [InlineData(float.NaN, float.NaN, float.NaN)]
1259 [InlineData(-0.0f, 0.0f, -0.0f)]
1260 [InlineData(2.0f, -3.0f, 2.0f)]
1261 [InlineData(3.0f, -2.0f, -2.0f)]
1262 [InlineData(float.PositiveInfinity, float.NaN, float.NaN)]
1263 public static void MinMagnitude(float x, float y, float expectedResult)
1265 AssertEqual(expectedResult, MathF.MinMagnitude(x, y), 0.0f);
1269 [InlineData(float.NegativeInfinity, float.NegativeInfinity, 0.0f, 0.0f)]
1270 [InlineData(float.NegativeInfinity, -1.0f, -0.0f, 0.0f)]
1271 [InlineData(float.NegativeInfinity, -0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1272 [InlineData(float.NegativeInfinity, float.NaN, float.NaN, 0.0f)]
1273 [InlineData(float.NegativeInfinity, 0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1274 [InlineData(float.NegativeInfinity, 1.0f, float.NegativeInfinity, 0.0f)]
1275 [InlineData(float.NegativeInfinity, float.PositiveInfinity, float.PositiveInfinity, 0.0f)]
1276 [InlineData(-10.0f, float.NegativeInfinity, 0.0f, 0.0f)]
1277 [InlineData(-10.0f, -1.57079633f, float.NaN, 0.0f)] // y: -(pi / 2)
1278 [InlineData(-10.0f, -1.0f, -0.1f, CrossPlatformMachineEpsilon)]
1279 [InlineData(-10.0f, -0.785398163f, float.NaN, 0.0f)] // y: -(pi / 4)
1280 [InlineData(-10.0f, -0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1281 [InlineData(-10.0f, float.NaN, float.NaN, 0.0f)]
1282 [InlineData(-10.0f, 0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1283 [InlineData(-10.0f, 0.785398163f, float.NaN, 0.0f)] // y: (pi / 4)
1284 [InlineData(-10.0f, 1.0f, -10.0f, CrossPlatformMachineEpsilon * 100)]
1285 [InlineData(-10.0f, 1.57079633f, float.NaN, 0.0f)] // y: (pi / 2)
1286 [InlineData(-10.0f, float.PositiveInfinity, float.PositiveInfinity, 0.0f)]
1287 [InlineData(-2.71828183f, float.NegativeInfinity, 0.0f, 0.0f)] // x: -(e)
1288 [InlineData(-2.71828183f, -1.57079633f, float.NaN, 0.0f)] // x: -(e) y: -(pi / 2)
1289 [InlineData(-2.71828183f, -1.0f, -0.367879441f, CrossPlatformMachineEpsilon)] // x: -(e)
1290 [InlineData(-2.71828183f, -0.785398163f, float.NaN, 0.0f)] // x: -(e) y: -(pi / 4)
1291 [InlineData(-2.71828183f, -0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)] // x: -(e)
1292 [InlineData(-2.71828183f, float.NaN, float.NaN, 0.0f)]
1293 [InlineData(-2.71828183f, 0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)] // x: -(e)
1294 [InlineData(-2.71828183f, 0.785398163f, float.NaN, 0.0f)] // x: -(e) y: (pi / 4)
1295 [InlineData(-2.71828183f, 1.0f, -2.71828183f, CrossPlatformMachineEpsilon * 10)] // x: -(e) expected: (e)
1296 [InlineData(-2.71828183f, 1.57079633f, float.NaN, 0.0f)] // x: -(e) y: (pi / 2)
1297 [InlineData(-2.71828183f, float.PositiveInfinity, float.PositiveInfinity, 0.0f)]
1298 [InlineData(-1.0f, -1.0f, -1.0f, CrossPlatformMachineEpsilon * 10)]
1299 [InlineData(-1.0f, -0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1300 [InlineData(-1.0f, float.NaN, float.NaN, 0.0f)]
1301 [InlineData(-1.0f, 0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1302 [InlineData(-1.0f, 1.0f, -1.0f, CrossPlatformMachineEpsilon * 10)]
1303 [InlineData(-0.0f, float.NegativeInfinity, float.PositiveInfinity, 0.0f)]
1304 [InlineData(-0.0f, -3.0f, float.NegativeInfinity, 0.0f)]
1305 [InlineData(-0.0f, -2.0f, float.PositiveInfinity, 0.0f)]
1306 [InlineData(-0.0f, -1.57079633f, float.PositiveInfinity, 0.0f)] // y: -(pi / 2)
1307 [InlineData(-0.0f, -1.0f, float.NegativeInfinity, 0.0f)]
1308 [InlineData(-0.0f, -0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1309 [InlineData(-0.0f, float.NaN, float.NaN, 0.0f)]
1310 [InlineData(-0.0f, 0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1311 [InlineData(-0.0f, 1.0f, -0.0f, 0.0f)]
1312 [InlineData(-0.0f, 1.57079633f, 0.0f, 0.0f)] // y: -(pi / 2)
1313 [InlineData(-0.0f, 2.0f, 0.0f, 0.0f)]
1314 [InlineData(-0.0f, 3.0f, -0.0f, 0.0f)]
1315 [InlineData(-0.0f, float.PositiveInfinity, 0.0f, 0.0f)]
1316 [InlineData(float.NaN, float.NegativeInfinity, float.NaN, 0.0f)]
1317 [InlineData(float.NaN, -1.0f, float.NaN, 0.0f)]
1318 [InlineData(float.NaN, float.NaN, float.NaN, 0.0f)]
1319 [InlineData(float.NaN, 1.0f, float.NaN, 0.0f)]
1320 [InlineData(float.NaN, float.PositiveInfinity, float.NaN, 0.0f)]
1321 [InlineData(0.0f, float.NegativeInfinity, float.PositiveInfinity, 0.0f)]
1322 [InlineData(0.0f, -3.0f, float.PositiveInfinity, 0.0f)]
1323 [InlineData(0.0f, -2.0f, float.PositiveInfinity, 0.0f)]
1324 [InlineData(0.0f, -1.57079633f, float.PositiveInfinity, 0.0f)] // y: -(pi / 2)
1325 [InlineData(0.0f, -1.0f, float.PositiveInfinity, 0.0f)]
1326 [InlineData(0.0f, -0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1327 [InlineData(0.0f, float.NaN, float.NaN, 0.0f)]
1328 [InlineData(0.0f, 0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1329 [InlineData(0.0f, 1.0f, 0.0f, 0.0f)]
1330 [InlineData(0.0f, 1.57079633f, 0.0f, 0.0f)] // y: -(pi / 2)
1331 [InlineData(0.0f, 2.0f, 0.0f, 0.0f)]
1332 [InlineData(0.0f, 3.0f, 0.0f, 0.0f)]
1333 [InlineData(0.0f, float.PositiveInfinity, 0.0f, 0.0f)]
1334 [InlineData(1.0f, float.NegativeInfinity, 1.0f, CrossPlatformMachineEpsilon * 10)]
1335 [InlineData(1.0f, -1.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1336 [InlineData(1.0f, -0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1337 [InlineData(1.0f, 0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1338 [InlineData(1.0f, 1.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1339 [InlineData(1.0f, float.PositiveInfinity, 1.0f, CrossPlatformMachineEpsilon * 10)]
1340 [InlineData(2.71828183f, float.NegativeInfinity, 0.0f, 0.0f)]
1341 [InlineData(2.71828183f, -3.14159265f, 0.0432139183f, CrossPlatformMachineEpsilon / 10)] // x: (e) y: -(pi)
1342 [InlineData(2.71828183f, -2.71828183f, 0.0659880358f, CrossPlatformMachineEpsilon / 10)] // x: (e) y: -(e)
1343 [InlineData(2.71828183f, -2.30258509f, 0.1f, CrossPlatformMachineEpsilon)] // x: (e) y: -(ln(10))
1344 [InlineData(2.71828183f, -1.57079633f, 0.207879576f, CrossPlatformMachineEpsilon)] // x: (e) y: -(pi / 2)
1345 [InlineData(2.71828183f, -1.44269504f, 0.236290088f, CrossPlatformMachineEpsilon)] // x: (e) y: -(log2(e))
1346 [InlineData(2.71828183f, -1.41421356f, 0.243116734f, CrossPlatformMachineEpsilon)] // x: (e) y: -(sqrt(2))
1347 [InlineData(2.71828183f, -1.12837917f, 0.323557264f, CrossPlatformMachineEpsilon)] // x: (e) y: -(2 / sqrt(pi))
1348 [InlineData(2.71828183f, -1.0f, 0.367879441f, CrossPlatformMachineEpsilon)] // x: (e)
1349 [InlineData(2.71828183f, -0.785398163f, 0.455938128f, CrossPlatformMachineEpsilon)] // x: (e) y: -(pi / 4)
1350 [InlineData(2.71828183f, -0.707106781f, 0.493068691f, CrossPlatformMachineEpsilon)] // x: (e) y: -(1 / sqrt(2))
1351 [InlineData(2.71828183f, -0.693147181f, 0.5f, CrossPlatformMachineEpsilon)] // x: (e) y: -(ln(2))
1352 [InlineData(2.71828183f, -0.636619772f, 0.529077808f, CrossPlatformMachineEpsilon)] // x: (e) y: -(2 / pi)
1353 [InlineData(2.71828183f, -0.434294482f, 0.647721485f, CrossPlatformMachineEpsilon)] // x: (e) y: -(log10(e))
1354 [InlineData(2.71828183f, -0.318309886f, 0.727377349f, CrossPlatformMachineEpsilon)] // x: (e) y: -(1 / pi)
1355 [InlineData(2.71828183f, -0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)] // x: (e)
1356 [InlineData(2.71828183f, float.NaN, float.NaN, 0.0f)]
1357 [InlineData(2.71828183f, 0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)] // x: (e)
1358 [InlineData(2.71828183f, 0.318309886f, 1.37480223f, CrossPlatformMachineEpsilon * 10)] // x: (e) y: (1 / pi)
1359 [InlineData(2.71828183f, 0.434294482f, 1.54387344f, CrossPlatformMachineEpsilon * 10)] // x: (e) y: (log10(e))
1360 [InlineData(2.71828183f, 0.636619772f, 1.89008116f, CrossPlatformMachineEpsilon * 10)] // x: (e) y: (2 / pi)
1361 [InlineData(2.71828183f, 0.693147181f, 2.0f, CrossPlatformMachineEpsilon * 10)] // x: (e) y: (ln(2))
1362 [InlineData(2.71828183f, 0.707106781f, 2.02811498f, CrossPlatformMachineEpsilon * 10)] // x: (e) y: (1 / sqrt(2))
1363 [InlineData(2.71828183f, 0.785398163f, 2.19328005f, CrossPlatformMachineEpsilon * 10)] // x: (e) y: (pi / 4)
1364 [InlineData(2.71828183f, 1.0f, 2.71828183f, CrossPlatformMachineEpsilon * 10)] // x: (e) expected: (e)
1365 [InlineData(2.71828183f, 1.12837917f, 3.09064302f, CrossPlatformMachineEpsilon * 10)] // x: (e) y: (2 / sqrt(pi))
1366 [InlineData(2.71828183f, 1.41421356f, 4.11325038f, CrossPlatformMachineEpsilon * 10)] // x: (e) y: (sqrt(2))
1367 [InlineData(2.71828183f, 1.44269504f, 4.23208611f, CrossPlatformMachineEpsilon * 10)] // x: (e) y: (log2(e))
1368 [InlineData(2.71828183f, 1.57079633f, 4.81047738f, CrossPlatformMachineEpsilon * 10)] // x: (e) y: (pi / 2)
1369 [InlineData(2.71828183f, 2.30258509f, 10.0f, CrossPlatformMachineEpsilon * 100)] // x: (e) y: (ln(10))
1370 [InlineData(2.71828183f, 2.71828183f, 15.1542622f, CrossPlatformMachineEpsilon * 100)] // x: (e) y: (e)
1371 [InlineData(2.71828183f, 3.14159265f, 23.1406926f, CrossPlatformMachineEpsilon * 100)] // x: (e) y: (pi)
1372 [InlineData(2.71828183f, float.PositiveInfinity, float.PositiveInfinity, 0.0f)] // x: (e)
1373 [InlineData(10.0f, float.NegativeInfinity, 0.0f, 0.0f)]
1374 [InlineData(10.0f, -3.14159265f, 0.000721784159f, CrossPlatformMachineEpsilon / 1000)] // y: -(pi)
1375 [InlineData(10.0f, -2.71828183f, 0.00191301410f, CrossPlatformMachineEpsilon / 100)] // y: -(e)
1376 [InlineData(10.0f, -2.30258509f, 0.00498212830f, CrossPlatformMachineEpsilon / 100)] // y: -(ln(10))
1377 [InlineData(10.0f, -1.57079633f, 0.0268660410f, CrossPlatformMachineEpsilon / 10)] // y: -(pi / 2)
1378 [InlineData(10.0f, -1.44269504f, 0.0360831928f, CrossPlatformMachineEpsilon / 10)] // y: -(log2(e))
1379 [InlineData(10.0f, -1.41421356f, 0.0385288847f, CrossPlatformMachineEpsilon / 10)] // y: -(sqrt(2))
1380 [InlineData(10.0f, -1.12837917f, 0.0744082059f, CrossPlatformMachineEpsilon / 10)] // y: -(2 / sqrt(pi))
1381 [InlineData(10.0f, -1.0f, 0.1f, CrossPlatformMachineEpsilon)]
1382 [InlineData(10.0f, -0.785398163f, 0.163908636f, CrossPlatformMachineEpsilon)] // y: -(pi / 4)
1383 [InlineData(10.0f, -0.707106781f, 0.196287760f, CrossPlatformMachineEpsilon)] // y: -(1 / sqrt(2))
1384 [InlineData(10.0f, -0.693147181f, 0.202699566f, CrossPlatformMachineEpsilon)] // y: -(ln(2))
1385 [InlineData(10.0f, -0.636619772f, 0.230876765f, CrossPlatformMachineEpsilon)] // y: -(2 / pi)
1386 [InlineData(10.0f, -0.434294482f, 0.367879441f, CrossPlatformMachineEpsilon)] // y: -(log10(e))
1387 [InlineData(10.0f, -0.318309886f, 0.480496373f, CrossPlatformMachineEpsilon)] // y: -(1 / pi)
1388 [InlineData(10.0f, -0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1389 [InlineData(10.0f, float.NaN, float.NaN, 0.0f)]
1390 [InlineData(10.0f, 0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1391 [InlineData(10.0f, 0.318309886f, 2.08118116f, CrossPlatformMachineEpsilon * 10)] // y: (1 / pi)
1392 [InlineData(10.0f, 0.434294482f, 2.71828183f, CrossPlatformMachineEpsilon * 10)] // y: (log10(e)) expected: (e)
1393 [InlineData(10.0f, 0.636619772f, 4.33131503f, CrossPlatformMachineEpsilon * 10)] // y: (2 / pi)
1394 [InlineData(10.0f, 0.693147181f, 4.93340967f, CrossPlatformMachineEpsilon * 10)] // y: (ln(2))
1395 [InlineData(10.0f, 0.707106781f, 5.09456117f, CrossPlatformMachineEpsilon * 10)] // y: (1 / sqrt(2))
1396 [InlineData(10.0f, 0.785398163f, 6.10095980f, CrossPlatformMachineEpsilon * 10)] // y: (pi / 4)
1397 [InlineData(10.0f, 1.0f, 10.0f, CrossPlatformMachineEpsilon * 100)]
1398 [InlineData(10.0f, 1.12837917f, 13.4393779f, CrossPlatformMachineEpsilon * 100)] // y: (2 / sqrt(pi))
1399 [InlineData(10.0f, 1.41421356f, 25.9545535f, CrossPlatformMachineEpsilon * 100)] // y: (sqrt(2))
1400 [InlineData(10.0f, 1.44269504f, 27.7137338f, CrossPlatformMachineEpsilon * 100)] // y: (log2(e))
1401 [InlineData(10.0f, 1.57079633f, 37.2217105f, CrossPlatformMachineEpsilon * 100)] // y: (pi / 2)
1402 [InlineData(10.0f, 2.30258509f, 200.717432f, CrossPlatformMachineEpsilon * 1000)] // y: (ln(10))
1403 [InlineData(10.0f, 2.71828183f, 522.735300f, CrossPlatformMachineEpsilon * 1000)] // y: (e)
1404 [InlineData(10.0f, 3.14159265f, 1385.45573f, CrossPlatformMachineEpsilon * 10000)] // y: (pi)
1405 [InlineData(10.0f, float.PositiveInfinity, float.PositiveInfinity, 0.0f)]
1406 [InlineData(float.PositiveInfinity, float.NegativeInfinity, 0.0f, 0.0f)]
1407 [InlineData(float.PositiveInfinity, -1.0f, 0.0f, 0.0f)]
1408 [InlineData(float.PositiveInfinity, -0.0f, 1.0f, 0.0f)]
1409 [InlineData(float.PositiveInfinity, float.NaN, float.NaN, 0.0f)]
1410 [InlineData(float.PositiveInfinity, 0.0f, 1.0f, 0.0f)]
1411 [InlineData(float.PositiveInfinity, 1.0f, float.PositiveInfinity, 0.0f)]
1412 [InlineData(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity, 0.0f)]
1413 public static void Pow(float x, float y, float expectedResult, float allowedVariance)
1415 AssertEqual(expectedResult, MathF.Pow(x, y), allowedVariance);
1419 [InlineData(-1.0f, float.NegativeInfinity, 1.0f, CrossPlatformMachineEpsilon * 10)]
1420 [InlineData(-1.0f, float.PositiveInfinity, 1.0f, CrossPlatformMachineEpsilon * 10)]
1421 [InlineData(float.NaN, -0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1422 [InlineData(float.NaN, 0.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1423 [InlineData(1.0f, float.NaN, 1.0f, CrossPlatformMachineEpsilon * 10)]
1424 public static void Pow_IEEE(float x, float y, float expectedResult, float allowedVariance)
1426 AssertEqual(expectedResult, MathF.Pow(x, y), allowedVariance);
1430 [InlineData( float.NegativeInfinity, -0.0f, 0.0f)]
1431 [InlineData(-3.14159265f, -0.318309873f, CrossPlatformMachineEpsilonForEstimates)] // value: (pi)
1432 [InlineData(-2.71828183f, -0.36787945f, CrossPlatformMachineEpsilonForEstimates)] // value: (e)
1433 [InlineData(-2.30258509f, -0.434294462f, CrossPlatformMachineEpsilonForEstimates)] // value: (ln(10))
1434 [InlineData(-1.57079633f, -0.636619747f, CrossPlatformMachineEpsilonForEstimates)] // value: (pi / 2)
1435 [InlineData(-1.44269504f, -0.693147182f, CrossPlatformMachineEpsilonForEstimates)] // value: (log2(e))
1436 [InlineData(-1.41421356f, -0.707106769f, CrossPlatformMachineEpsilonForEstimates)] // value: (sqrt(2))
1437 [InlineData(-1.12837917f, -0.886226892f, CrossPlatformMachineEpsilonForEstimates)] // value: (2 / sqrt(pi))
1438 [InlineData(-1.0f, -1.0f, CrossPlatformMachineEpsilonForEstimates)]
1439 [InlineData(-0.785398163f, -1.27323949f, CrossPlatformMachineEpsilonForEstimates)] // value: (pi / 4)
1440 [InlineData(-0.707106781f, -1.41421354f, CrossPlatformMachineEpsilonForEstimates)] // value: (1 / sqrt(2))
1441 [InlineData(-0.693147181f, -1.44269502f, CrossPlatformMachineEpsilonForEstimates)] // value: (ln(2))
1442 [InlineData(-0.636619772f, -1.57079637f, CrossPlatformMachineEpsilonForEstimates)] // value: (2 / pi)
1443 [InlineData(-0.434294482f, -2.30258512f, CrossPlatformMachineEpsilonForEstimates)] // value: (log10(e))
1444 [InlineData(-0.318309886f, -3.14159274f, CrossPlatformMachineEpsilonForEstimates)] // value: (1 / pi)
1445 [InlineData(-0.0f, float.NegativeInfinity, 0.0f)]
1446 [InlineData( float.NaN, float.NaN, 0.0f)]
1447 [InlineData( 0.0f, float.PositiveInfinity, 0.0f)]
1448 [InlineData( 0.318309886f, 3.14159274f, CrossPlatformMachineEpsilonForEstimates)] // value: (1 / pi)
1449 [InlineData( 0.434294482f, 2.30258512f, CrossPlatformMachineEpsilonForEstimates)] // value: (log10(e))
1450 [InlineData( 0.636619772f, 1.57079637f, CrossPlatformMachineEpsilonForEstimates)] // value: (2 / pi)
1451 [InlineData( 0.693147181f, 1.44269502f, CrossPlatformMachineEpsilonForEstimates)] // value: (ln(2))
1452 [InlineData( 0.707106781f, 1.41421354f, CrossPlatformMachineEpsilonForEstimates)] // value: (1 / sqrt(2))
1453 [InlineData( 0.785398163f, 1.27323949f, CrossPlatformMachineEpsilonForEstimates)] // value: (pi / 4)
1454 [InlineData( 1.0f, 1.0f, CrossPlatformMachineEpsilonForEstimates)]
1455 [InlineData( 1.12837917f, 0.886226892f, CrossPlatformMachineEpsilonForEstimates)] // value: (2 / sqrt(pi))
1456 [InlineData( 1.41421356f, 0.707106769f, CrossPlatformMachineEpsilonForEstimates)] // value: (sqrt(2))
1457 [InlineData( 1.44269504f, 0.693147182f, CrossPlatformMachineEpsilonForEstimates)] // value: (log2(e))
1458 [InlineData( 1.57079633f, 0.636619747f, CrossPlatformMachineEpsilonForEstimates)] // value: (pi / 2)
1459 [InlineData( 2.30258509f, 0.434294462f, CrossPlatformMachineEpsilonForEstimates)] // value: (ln(10))
1460 [InlineData( 2.71828183f, 0.36787945f, CrossPlatformMachineEpsilonForEstimates)] // value: (e)
1461 [InlineData( 3.14159265f, 0.318309873f, CrossPlatformMachineEpsilonForEstimates)] // value: (pi)
1462 [InlineData( float.PositiveInfinity, 0.0f, 0.0f)]
1463 public static void ReciprocalEstimate(float value, float expectedResult, float allowedVariance)
1465 AssertEqual(expectedResult, MathF.ReciprocalEstimate(value), allowedVariance);
1469 [InlineData( float.NegativeInfinity, float.NaN, 0.0f)]
1470 [InlineData(-3.14159265f, float.NaN, 0.0f)] // value: (pi)
1471 [InlineData(-2.71828183f, float.NaN, 0.0f)] // value: (e)
1472 [InlineData(-2.30258509f, float.NaN, 0.0f)] // value: (ln(10))
1473 [InlineData(-1.57079633f, float.NaN, 0.0f)] // value: (pi / 2)
1474 [InlineData(-1.44269504f, float.NaN, 0.0f)] // value: (log2(e))
1475 [InlineData(-1.41421356f, float.NaN, 0.0f)] // value: (sqrt(2))
1476 [InlineData(-1.12837917f, float.NaN, 0.0f)] // value: (2 / sqrt(pi))
1477 [InlineData(-1.0f, float.NaN, 0.0f)]
1478 [InlineData(-0.785398163f, float.NaN, 0.0f)] // value: (pi / 4)
1479 [InlineData(-0.707106781f, float.NaN, 0.0f)] // value: (1 / sqrt(2))
1480 [InlineData(-0.693147181f, float.NaN, 0.0f)] // value: (ln(2))
1481 [InlineData(-0.636619772f, float.NaN, 0.0f)] // value: (2 / pi)
1482 [InlineData(-0.434294482f, float.NaN, 0.0f)] // value: (log10(e))
1483 [InlineData(-0.318309886f, float.NaN, 0.0f)] // value: (1 / pi)
1484 [InlineData(-0.0f, float.NegativeInfinity, 0.0f)]
1485 [InlineData( float.NaN, float.NaN, 0.0f)]
1486 [InlineData( 0.0f, float.PositiveInfinity, 0.0f)]
1487 [InlineData( 0.318309886f, 1.7724539f, CrossPlatformMachineEpsilonForEstimates)] // value: (1 / pi)
1488 [InlineData( 0.434294482f, 1.51742709f, CrossPlatformMachineEpsilonForEstimates)] // value: (log10(e))
1489 [InlineData( 0.636619772f, 1.25331414f, CrossPlatformMachineEpsilonForEstimates)] // value: (2 / pi)
1490 [InlineData( 0.693147181f, 1.2011224f, CrossPlatformMachineEpsilonForEstimates)] // value: (ln(2))
1491 [InlineData( 0.707106781f, 1.18920708f, CrossPlatformMachineEpsilonForEstimates)] // value: (1 / sqrt(2))
1492 [InlineData( 0.785398163f, 1.12837911f, CrossPlatformMachineEpsilonForEstimates)] // value: (pi / 4)
1493 [InlineData( 1.0f, 1.0f, CrossPlatformMachineEpsilonForEstimates)]
1494 [InlineData( 1.12837917f, 0.941396296f, CrossPlatformMachineEpsilonForEstimates)] // value: (2 / sqrt(pi))
1495 [InlineData( 1.41421356f, 0.840896428f, CrossPlatformMachineEpsilonForEstimates)] // value: (sqrt(2))
1496 [InlineData( 1.44269504f, 0.832554638f, CrossPlatformMachineEpsilonForEstimates)] // value: (log2(e))
1497 [InlineData( 1.57079633f, 0.797884583f, CrossPlatformMachineEpsilonForEstimates)] // value: (pi / 2)
1498 [InlineData( 2.30258509f, 0.659010231f, CrossPlatformMachineEpsilonForEstimates)] // value: (ln(10))
1499 [InlineData( 2.71828183f, 0.606530666f, CrossPlatformMachineEpsilonForEstimates)] // value: (e)
1500 [InlineData( 3.14159265f, 0.564189553f, CrossPlatformMachineEpsilonForEstimates)] // value: (pi)
1501 [InlineData( float.PositiveInfinity, 0.0f, 0.0f)]
1502 public static void ReciprocalSqrtEstimate(float value, float expectedResult, float allowedVariance)
1504 AssertEqual(expectedResult, MathF.ReciprocalSqrtEstimate(value), allowedVariance);
1507 public static IEnumerable<object[]> Round_Digits_TestData
1511 yield return new object[] { float.NaN, float.NaN, 3, MidpointRounding.ToEven };
1512 yield return new object[] { float.PositiveInfinity, float.PositiveInfinity, 3, MidpointRounding.ToEven };
1513 yield return new object[] { float.NegativeInfinity, float.NegativeInfinity, 3, MidpointRounding.ToEven };
1514 yield return new object[] { 0, 0, 3, MidpointRounding.ToEven };
1515 yield return new object[] { 3.42156f, 3.422f, 3, MidpointRounding.ToEven };
1516 yield return new object[] { -3.42156f, -3.422f, 3, MidpointRounding.ToEven };
1518 yield return new object[] { float.NaN, float.NaN, 3, MidpointRounding.AwayFromZero };
1519 yield return new object[] { float.PositiveInfinity, float.PositiveInfinity, 3, MidpointRounding.AwayFromZero };
1520 yield return new object[] { float.NegativeInfinity, float.NegativeInfinity, 3, MidpointRounding.AwayFromZero };
1521 yield return new object[] { 0, 0, 3, MidpointRounding.AwayFromZero };
1522 yield return new object[] { 3.42156f, 3.422f, 3, MidpointRounding.AwayFromZero };
1523 yield return new object[] { -3.42156f, -3.422f, 3, MidpointRounding.AwayFromZero };
1525 yield return new object[] { float.NaN, float.NaN, 3, MidpointRounding.ToZero };
1526 yield return new object[] { float.PositiveInfinity, float.PositiveInfinity, 3, MidpointRounding.ToZero };
1527 yield return new object[] { float.NegativeInfinity, float.NegativeInfinity, 3, MidpointRounding.ToZero };
1528 yield return new object[] { 0, 0, 3, MidpointRounding.ToZero };
1529 yield return new object[] { 3.42156f, 3.421f, 3, MidpointRounding.ToZero };
1530 yield return new object[] { -3.42156f, -3.421f, 3, MidpointRounding.ToZero };
1532 yield return new object[] { float.NaN, float.NaN, 3, MidpointRounding.ToNegativeInfinity };
1533 yield return new object[] { float.PositiveInfinity, float.PositiveInfinity, 3, MidpointRounding.ToNegativeInfinity };
1534 yield return new object[] { float.NegativeInfinity, float.NegativeInfinity, 3, MidpointRounding.ToNegativeInfinity };
1535 yield return new object[] { 0, 0, 3, MidpointRounding.ToNegativeInfinity };
1536 yield return new object[] { 3.42156f, 3.421f, 3, MidpointRounding.ToNegativeInfinity };
1537 yield return new object[] { -3.42156f, -3.422f, 3, MidpointRounding.ToNegativeInfinity };
1539 yield return new object[] { float.NaN, float.NaN, 3, MidpointRounding.ToPositiveInfinity };
1540 yield return new object[] { float.PositiveInfinity, float.PositiveInfinity, 3, MidpointRounding.ToPositiveInfinity };
1541 yield return new object[] { float.NegativeInfinity, float.NegativeInfinity, 3, MidpointRounding.ToPositiveInfinity };
1542 yield return new object[] { 0, 0, 3, MidpointRounding.ToPositiveInfinity };
1543 yield return new object[] { 3.42156f, 3.422f, 3, MidpointRounding.ToPositiveInfinity };
1544 yield return new object[] { -3.42156f, -3.421f, 3, MidpointRounding.ToPositiveInfinity };
1549 public static void Round()
1551 Assert.Equal(0.0f, MathF.Round(0.0f));
1552 Assert.Equal(1.0f, MathF.Round(1.4f));
1553 Assert.Equal(2.0f, MathF.Round(1.5f));
1554 Assert.Equal(2e7f, MathF.Round(2e7f));
1555 Assert.Equal(0.0f, MathF.Round(-0.0f));
1556 Assert.Equal(-1.0f, MathF.Round(-1.4f));
1557 Assert.Equal(-2.0f, MathF.Round(-1.5f));
1558 Assert.Equal(-2e7f, MathF.Round(-2e7f));
1562 [InlineData(MidpointRounding.ToEven)]
1563 [InlineData(MidpointRounding.AwayFromZero)]
1564 [InlineData(MidpointRounding.ToNegativeInfinity)]
1565 [InlineData(MidpointRounding.ToPositiveInfinity)]
1566 public static void Round_Digits_ByMidpointRounding(MidpointRounding mode)
1568 Assert.Equal(float.PositiveInfinity, MathF.Round(float.PositiveInfinity, 3, mode));
1569 Assert.Equal(float.NegativeInfinity, MathF.Round(float.NegativeInfinity, 3, mode));
1573 [MemberData(nameof(Round_Digits_TestData))]
1574 public static void Round_Digits(float x, float expected, int digits, MidpointRounding mode)
1576 AssertEqual(expected, MathF.Round(x, digits, mode), CrossPlatformMachineEpsilon * 10);
1580 [InlineData(float.NegativeInfinity, unchecked((int)(0x7FFFFFFF)), float.NegativeInfinity, 0)]
1581 [InlineData(float.PositiveInfinity, unchecked((int)(0x7FFFFFFF)), float.PositiveInfinity, 0)]
1582 [InlineData(float.NaN, 0, float.NaN, 0)]
1583 [InlineData(float.NaN, 0, float.NaN, 0)]
1584 [InlineData(float.PositiveInfinity, 0, float.PositiveInfinity, 0)]
1585 [InlineData(float.NaN, 0, float.NaN, 0)]
1586 [InlineData(float.NaN, 1, float.NaN, 0)]
1587 [InlineData(float.PositiveInfinity, 2147483647, float.PositiveInfinity, 0)]
1588 [InlineData(float.PositiveInfinity, -2147483647, float.PositiveInfinity, 0)]
1589 [InlineData(float.NaN, 2147483647, float.NaN, 0)]
1590 [InlineData(-0.0f, unchecked((int)(0x80000000)), -0.0f, 0)]
1591 [InlineData(float.NaN, unchecked((int)(0x7FFFFFFF)), float.NaN, 0)]
1592 [InlineData(0, unchecked((int)(0x80000000)), 0, 0)]
1593 [InlineData(0.113314732f, -4, 0.00708217081f, CrossPlatformMachineEpsilon / 100)]
1594 [InlineData(-0.113314732f, -3, -0.0141643415f, CrossPlatformMachineEpsilon / 10)]
1595 [InlineData(0.151955223f, -3, 0.0189944021f, CrossPlatformMachineEpsilon / 10)]
1596 [InlineData(0.202699566f, -3, 0.0253374465f, CrossPlatformMachineEpsilon / 10)]
1597 [InlineData(0.336622537f, -2, 0.084155634f, CrossPlatformMachineEpsilon / 10)]
1598 [InlineData(0.367879441f, -2, 0.0919698626f, CrossPlatformMachineEpsilon / 10)]
1599 [InlineData(0.375214227f, -2, 0.0938035548f, CrossPlatformMachineEpsilon / 10)]
1600 [InlineData(0.457429347f, -2, 0.114357337f, CrossPlatformMachineEpsilon)]
1601 [InlineData(0.5f, -1, 0.25f, CrossPlatformMachineEpsilon)]
1602 [InlineData(0.580191810f, -1, 0.290095896f, CrossPlatformMachineEpsilon)]
1603 [InlineData(0.612547327f, -1, 0.306273669f, CrossPlatformMachineEpsilon)]
1604 [InlineData(0.618503138f, -1, 0.309251577f, CrossPlatformMachineEpsilon)]
1605 [InlineData(0.643218242f, -1, 0.321609110f, CrossPlatformMachineEpsilon)]
1606 [InlineData(0.740055574f, -1, 0.370027781f, CrossPlatformMachineEpsilon)]
1607 [InlineData(0.802008879f, -1, 0.401004434f, CrossPlatformMachineEpsilon)]
1608 [InlineData(0, 2147483647, 0, CrossPlatformMachineEpsilon)]
1609 [InlineData(0, -2147483647, 0, CrossPlatformMachineEpsilon)]
1610 [InlineData(0, 2147483647, 0, CrossPlatformMachineEpsilon)]
1611 [InlineData(1, -1, 0.5, CrossPlatformMachineEpsilon)]
1612 [InlineData(1, 0, 1, CrossPlatformMachineEpsilon * 10)]
1613 [InlineData(1.24686899f, 0, 1.24686899f, CrossPlatformMachineEpsilon * 10)]
1614 [InlineData(1.35124987f, 0, 1.35124987f, CrossPlatformMachineEpsilon * 10)]
1615 [InlineData(1.55468228f, 0, 1.55468228f, CrossPlatformMachineEpsilon * 10)]
1616 [InlineData(1.61680667f, 0, 1.61680667f, CrossPlatformMachineEpsilon * 10)]
1617 [InlineData(1.63252692f, 0, 1.63252692f, CrossPlatformMachineEpsilon * 10)]
1618 [InlineData(1.72356793f, 0, 1.72356793f, CrossPlatformMachineEpsilon * 10)]
1619 [InlineData(2, 1, 4, CrossPlatformMachineEpsilon * 10)]
1620 [InlineData(2.18612996f, 1, 4.37225992f, CrossPlatformMachineEpsilon * 10)]
1621 [InlineData(2.66514414f, 1, 5.33028829f, CrossPlatformMachineEpsilon * 10)]
1622 [InlineData(2.71828183f, 1, 5.43656366f, CrossPlatformMachineEpsilon * 10)]
1623 [InlineData(2.97068642f, 1, 5.94137285f, CrossPlatformMachineEpsilon * 10)]
1624 [InlineData(1, 0, 1, CrossPlatformMachineEpsilon * 10)]
1625 [InlineData(1, 1, 2, CrossPlatformMachineEpsilon * 10)]
1626 [InlineData(1.7014118E+38, -276, 1E-45, CrossPlatformMachineEpsilon * 10)]
1627 [InlineData(1E-45, 276, 1.7014118E+38, CrossPlatformMachineEpsilon * 10)]
1628 [InlineData(1.0002441, -149, 1E-45, CrossPlatformMachineEpsilon * 10)]
1629 [InlineData(0.74999994, -148, 1E-45, CrossPlatformMachineEpsilon * 10)]
1630 [InlineData(0.50000066, -128, 1.46937E-39, CrossPlatformMachineEpsilon * 10)]
1631 [InlineData(-8.066849, -2, -2.0167122, CrossPlatformMachineEpsilon * 10)]
1632 [InlineData(4.3452396, -1, 2.1726198, CrossPlatformMachineEpsilon * 10)]
1633 [InlineData(-8.3814335, 0, -8.3814335, CrossPlatformMachineEpsilon * 10)]
1634 [InlineData(0.6619859, 3, 5.295887, CrossPlatformMachineEpsilon * 10)]
1635 [InlineData(-0.40660393, 4, -6.505663, CrossPlatformMachineEpsilon * 10)]
1636 [InlineData(-6.5316734, 1, -13.063347, CrossPlatformMachineEpsilon * 100)]
1637 [InlineData(9.267057, 2, 37.06823, CrossPlatformMachineEpsilon * 100)]
1638 [InlineData(0.56175977, 5, 17.976313, CrossPlatformMachineEpsilon * 100)]
1639 [InlineData(0.7741523, 6, 49.545746, CrossPlatformMachineEpsilon * 100)]
1640 [InlineData(-0.6787637, 7, -86.88175, CrossPlatformMachineEpsilon * 100)]
1641 [InlineData(4.93340967f, 2, 19.7336387f, CrossPlatformMachineEpsilon * 100)]
1642 [InlineData(6.58088599f, 2, 26.3235440f, CrossPlatformMachineEpsilon * 100)]
1643 [InlineData(8.82497783f, 3, 70.5998226f, CrossPlatformMachineEpsilon * 100)]
1644 public static void ScaleB(float x, int n, float expectedResult, float allowedVariance)
1646 AssertEqual(expectedResult, MathF.ScaleB(x, n), allowedVariance);
1650 public static void Sign()
1652 Assert.Equal(0, MathF.Sign(0.0f));
1653 Assert.Equal(0, MathF.Sign(-0.0f));
1654 Assert.Equal(-1, MathF.Sign(-3.14f));
1655 Assert.Equal(1, MathF.Sign(3.14f));
1656 Assert.Equal(-1, MathF.Sign(float.NegativeInfinity));
1657 Assert.Equal(1, MathF.Sign(float.PositiveInfinity));
1658 Assert.Throws<ArithmeticException>(() => MathF.Sign(float.NaN));
1662 [InlineData(float.NegativeInfinity, float.NaN, 0.0f)]
1663 [InlineData(-3.14159265f, -0.0f, CrossPlatformMachineEpsilon)] // value: -(pi)
1664 [InlineData(-2.71828183f, -0.410781291f, CrossPlatformMachineEpsilon)] // value: -(e)
1665 [InlineData(-2.30258509f, -0.743980337f, CrossPlatformMachineEpsilon)] // value: -(ln(10))
1666 [InlineData(-1.57079633f, -1.0f, CrossPlatformMachineEpsilon * 10)] // value: -(pi / 2)
1667 [InlineData(-1.44269504f, -0.991806244f, CrossPlatformMachineEpsilon)] // value: -(log2(e))
1668 [InlineData(-1.41421356f, -0.987765946f, CrossPlatformMachineEpsilon)] // value: -(sqrt(2))
1669 [InlineData(-1.12837917f, -0.903719457f, CrossPlatformMachineEpsilon)] // value: -(2 / sqrt(pi))
1670 [InlineData(-1.0f, -0.841470985f, CrossPlatformMachineEpsilon)]
1671 [InlineData(-0.785398163f, -0.707106781f, CrossPlatformMachineEpsilon)] // value: -(pi / 4), expected: -(1 / sqrt(2))
1672 [InlineData(-0.707106781f, -0.649636939f, CrossPlatformMachineEpsilon)] // value: -(1 / sqrt(2))
1673 [InlineData(-0.693147181f, -0.638961276f, CrossPlatformMachineEpsilon)] // value: -(ln(2))
1674 [InlineData(-0.636619772f, -0.594480769f, CrossPlatformMachineEpsilon)] // value: -(2 / pi)
1675 [InlineData(-0.434294482f, -0.420770483f, CrossPlatformMachineEpsilon)] // value: -(log10(e))
1676 [InlineData(-0.318309886f, -0.312961796f, CrossPlatformMachineEpsilon)] // value: -(1 / pi)
1677 [InlineData(-0.0f, -0.0f, 0.0f)]
1678 [InlineData(float.NaN, float.NaN, 0.0f)]
1679 [InlineData(0.0f, 0.0f, 0.0f)]
1680 [InlineData(0.318309886f, 0.312961796f, CrossPlatformMachineEpsilon)] // value: (1 / pi)
1681 [InlineData(0.434294482f, 0.420770483f, CrossPlatformMachineEpsilon)] // value: (log10(e))
1682 [InlineData(0.636619772f, 0.594480769f, CrossPlatformMachineEpsilon)] // value: (2 / pi)
1683 [InlineData(0.693147181f, 0.638961276f, CrossPlatformMachineEpsilon)] // value: (ln(2))
1684 [InlineData(0.707106781f, 0.649636939f, CrossPlatformMachineEpsilon)] // value: (1 / sqrt(2))
1685 [InlineData(0.785398163f, 0.707106781f, CrossPlatformMachineEpsilon)] // value: (pi / 4), expected: (1 / sqrt(2))
1686 [InlineData(1.0f, 0.841470985f, CrossPlatformMachineEpsilon)]
1687 [InlineData(1.12837917f, 0.903719457f, CrossPlatformMachineEpsilon)] // value: (2 / sqrt(pi))
1688 [InlineData(1.41421356f, 0.987765946f, CrossPlatformMachineEpsilon)] // value: (sqrt(2))
1689 [InlineData(1.44269504f, 0.991806244f, CrossPlatformMachineEpsilon)] // value: (log2(e))
1690 [InlineData(1.57079633f, 1.0f, CrossPlatformMachineEpsilon * 10)] // value: (pi / 2)
1691 [InlineData(2.30258509f, 0.743980337f, CrossPlatformMachineEpsilon)] // value: (ln(10))
1692 [InlineData(2.71828183f, 0.410781291f, CrossPlatformMachineEpsilon)] // value: (e)
1693 [InlineData(3.14159265f, 0.0f, CrossPlatformMachineEpsilon)] // value: (pi)
1694 [InlineData(float.PositiveInfinity, float.NaN, 0.0f)]
1695 public static void Sin(float value, float expectedResult, float allowedVariance)
1697 AssertEqual(expectedResult, MathF.Sin(value), allowedVariance);
1701 [InlineData( float.NegativeInfinity, float.NaN, float.NaN, 0.0f, 0.0f)]
1702 [InlineData(-3.14159265f, -0.0f, -1.0f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon * 10)] // value: -(pi)
1703 [InlineData(-2.71828183f, -0.410781291f, -0.911733918f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: -(e)
1704 [InlineData(-2.30258509f, -0.743980337f, -0.668201510f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: -(ln(10))
1705 [InlineData(-1.57079633f, -1.0f, 0.0f, CrossPlatformMachineEpsilon * 10, CrossPlatformMachineEpsilon)] // value: -(pi / 2)
1706 [InlineData(-1.44269504f, -0.991806244f, 0.127751218f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: -(log2(e))
1707 [InlineData(-1.41421356f, -0.987765946f, 0.155943695f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: -(sqrt(2))
1708 [InlineData(-1.12837917f, -0.903719457f, 0.428125148f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: -(2 / sqrt(pi))
1709 [InlineData(-1.0f, -0.841470985f, 0.540302306f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)]
1710 [InlineData(-0.785398163f, -0.707106781f, 0.707106781f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: -(pi / 4), expected_sin: -(1 / sqrt(2)), expected_cos: 1
1711 [InlineData(-0.707106781f, -0.649636939f, 0.760244597f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: -(1 / sqrt(2))
1712 [InlineData(-0.693147181f, -0.638961276f, 0.769238901f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: -(ln(2))
1713 [InlineData(-0.636619772f, -0.594480769f, 0.804109828f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: -(2 / pi)
1714 [InlineData(-0.434294482f, -0.420770483f, 0.907167129f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: -(log10(e))
1715 [InlineData(-0.318309886f, -0.312961796f, 0.949765715f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: -(1 / pi)
1716 [InlineData(-0.0f, -0.0f, 1.0f, 0.0f, CrossPlatformMachineEpsilon * 10)]
1717 [InlineData( float.NaN, float.NaN, float.NaN, 0.0f, 0.0f)]
1718 [InlineData( 0.0f, 0.0f, 1.0f, 0.0f, CrossPlatformMachineEpsilon * 10)]
1719 [InlineData( 0.318309886f, 0.312961796f, 0.949765715f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: (1 / pi)
1720 [InlineData( 0.434294482f, 0.420770483f, 0.907167129f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: (log10(e))
1721 [InlineData( 0.636619772f, 0.594480769f, 0.804109828f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: (2 / pi)
1722 [InlineData( 0.693147181f, 0.638961276f, 0.769238901f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: (ln(2))
1723 [InlineData( 0.707106781f, 0.649636939f, 0.760244597f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: (1 / sqrt(2))
1724 [InlineData( 0.785398163f, 0.707106781f, 0.707106781f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: (pi / 4), expected_sin: (1 / sqrt(2)), expected_cos: 1
1725 [InlineData( 1.0f, 0.841470985f, 0.540302306f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)]
1726 [InlineData( 1.12837917f, 0.903719457f, 0.428125148f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: (2 / sqrt(pi))
1727 [InlineData( 1.41421356f, 0.987765946f, 0.155943695f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: (sqrt(2))
1728 [InlineData( 1.44269504f, 0.991806244f, 0.127751218f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: (log2(e))
1729 [InlineData( 1.57079633f, 1.0f, 0.0f, CrossPlatformMachineEpsilon * 10, CrossPlatformMachineEpsilon)] // value: (pi / 2)
1730 [InlineData( 2.30258509f, 0.743980337f, -0.668201510f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: (ln(10))
1731 [InlineData( 2.71828183f, 0.410781291f, -0.911733918f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon)] // value: (e)
1732 [InlineData( 3.14159265f, 0.0f, -1.0f, CrossPlatformMachineEpsilon, CrossPlatformMachineEpsilon * 10)] // value: (pi)
1733 [InlineData( float.PositiveInfinity, float.NaN, float.NaN, 0.0f, 0.0f)]
1734 public static void SinCos(float value, float expectedResultSin, float expectedResultCos, float allowedVarianceSin, float allowedVarianceCos)
1736 (float resultSin, float resultCos) = MathF.SinCos(value);
1737 AssertEqual(expectedResultSin, resultSin, allowedVarianceSin);
1738 AssertEqual(expectedResultCos, resultCos, allowedVarianceCos);
1742 [InlineData( float.NegativeInfinity, float.NegativeInfinity, 0.0f)]
1743 [InlineData(-3.14159265f, -11.5487394f, CrossPlatformMachineEpsilon * 100)] // value: -(pi)
1744 [InlineData(-2.71828183f, -7.54413710f, CrossPlatformMachineEpsilon * 10)] // value: -(e)
1745 [InlineData(-2.30258509f, -4.95f, CrossPlatformMachineEpsilon * 10)] // value: -(ln(10))
1746 [InlineData(-1.57079633f, -2.30129890f, CrossPlatformMachineEpsilon * 10)] // value: -(pi / 2)
1747 [InlineData(-1.44269504f, -1.99789801f, CrossPlatformMachineEpsilon * 10)] // value: -(log2(e))
1748 [InlineData(-1.41421356f, -1.93506682f, CrossPlatformMachineEpsilon * 10)] // value: -(sqrt(2))
1749 [InlineData(-1.12837917f, -1.38354288f, CrossPlatformMachineEpsilon * 10)] // value: -(2 / sqrt(pi))
1750 [InlineData(-1.0f, -1.17520119f, CrossPlatformMachineEpsilon * 10)]
1751 [InlineData(-0.785398163f, -0.868670961f, CrossPlatformMachineEpsilon)] // value: -(pi / 4)
1752 [InlineData(-0.707106781f, -0.767523145f, CrossPlatformMachineEpsilon)] // value: -(1 / sqrt(2))
1753 [InlineData(-0.693147181f, -0.75f, CrossPlatformMachineEpsilon)] // value: -(ln(2))
1754 [InlineData(-0.636619772f, -0.680501678f, CrossPlatformMachineEpsilon)] // value: -(2 / pi)
1755 [InlineData(-0.434294482f, -0.448075979f, CrossPlatformMachineEpsilon)] // value: -(log10(e))
1756 [InlineData(-0.318309886f, -0.323712439f, CrossPlatformMachineEpsilon)] // value: -(1 / pi)
1757 [InlineData(-0.0f, -0.0f, 0.0f)]
1758 [InlineData( float.NaN, float.NaN, 0.0f)]
1759 [InlineData( 0.0f, 0.0f, 0.0f)]
1760 [InlineData( 0.318309886f, 0.323712439f, CrossPlatformMachineEpsilon)] // value: (1 / pi)
1761 [InlineData( 0.434294482f, 0.448075979f, CrossPlatformMachineEpsilon)] // value: (log10(e))
1762 [InlineData( 0.636619772f, 0.680501678f, CrossPlatformMachineEpsilon)] // value: (2 / pi)
1763 [InlineData( 0.693147181f, 0.75f, CrossPlatformMachineEpsilon)] // value: (ln(2))
1764 [InlineData( 0.707106781f, 0.767523145f, CrossPlatformMachineEpsilon)] // value: (1 / sqrt(2))
1765 [InlineData( 0.785398163f, 0.868670961f, CrossPlatformMachineEpsilon)] // value: (pi / 4)
1766 [InlineData( 1.0f, 1.17520119f, CrossPlatformMachineEpsilon * 10)]
1767 [InlineData( 1.12837917f, 1.38354288f, CrossPlatformMachineEpsilon * 10)] // value: (2 / sqrt(pi))
1768 [InlineData( 1.41421356f, 1.93506682f, CrossPlatformMachineEpsilon * 10)] // value: (sqrt(2))
1769 [InlineData( 1.44269504f, 1.99789801f, CrossPlatformMachineEpsilon * 10)] // value: (log2(e))
1770 [InlineData( 1.57079633f, 2.30129890f, CrossPlatformMachineEpsilon * 10)] // value: (pi / 2)
1771 [InlineData( 2.30258509f, 4.95f, CrossPlatformMachineEpsilon * 10)] // value: (ln(10))
1772 [InlineData( 2.71828183f, 7.54413710f, CrossPlatformMachineEpsilon * 10)] // value: (e)
1773 [InlineData( 3.14159265f, 11.5487394f, CrossPlatformMachineEpsilon * 100)] // value: (pi)
1774 [InlineData( float.PositiveInfinity, float.PositiveInfinity, 0.0f)]
1775 public static void Sinh(float value, float expectedResult, float allowedVariance)
1777 AssertEqual(expectedResult, MathF.Sinh(value), allowedVariance);
1781 [InlineData(float.NegativeInfinity, float.NaN, 0.0f)]
1782 [InlineData(-3.14159265f, float.NaN, 0.0f)] // value: (pi)
1783 [InlineData(-2.71828183f, float.NaN, 0.0f)] // value: (e)
1784 [InlineData(-2.30258509f, float.NaN, 0.0f)] // value: (ln(10))
1785 [InlineData(-1.57079633f, float.NaN, 0.0f)] // value: (pi / 2)
1786 [InlineData(-1.44269504f, float.NaN, 0.0f)] // value: (log2(e))
1787 [InlineData(-1.41421356f, float.NaN, 0.0f)] // value: (sqrt(2))
1788 [InlineData(-1.12837917f, float.NaN, 0.0f)] // value: (2 / sqrt(pi))
1789 [InlineData(-1.0f, float.NaN, 0.0f)]
1790 [InlineData(-0.785398163f, float.NaN, 0.0f)] // value: (pi / 4)
1791 [InlineData(-0.707106781f, float.NaN, 0.0f)] // value: (1 / sqrt(2))
1792 [InlineData(-0.693147181f, float.NaN, 0.0f)] // value: (ln(2))
1793 [InlineData(-0.636619772f, float.NaN, 0.0f)] // value: (2 / pi)
1794 [InlineData(-0.434294482f, float.NaN, 0.0f)] // value: (log10(e))
1795 [InlineData(-0.318309886f, float.NaN, 0.0f)] // value: (1 / pi)
1796 [InlineData(-0.0f, -0.0f, 0.0f)]
1797 [InlineData(float.NaN, float.NaN, 0.0f)]
1798 [InlineData(0.0f, 0.0f, 0.0f)]
1799 [InlineData(0.318309886f, 0.564189584f, CrossPlatformMachineEpsilon)] // value: (1 / pi)
1800 [InlineData(0.434294482f, 0.659010229f, CrossPlatformMachineEpsilon)] // value: (log10(e))
1801 [InlineData(0.636619772f, 0.797884561f, CrossPlatformMachineEpsilon)] // value: (2 / pi)
1802 [InlineData(0.693147181f, 0.832554611f, CrossPlatformMachineEpsilon)] // value: (ln(2))
1803 [InlineData(0.707106781f, 0.840896415f, CrossPlatformMachineEpsilon)] // value: (1 / sqrt(2))
1804 [InlineData(0.785398163f, 0.886226925f, CrossPlatformMachineEpsilon)] // value: (pi / 4)
1805 [InlineData(1.0f, 1.0f, CrossPlatformMachineEpsilon * 10)]
1806 [InlineData(1.12837917f, 1.06225193f, CrossPlatformMachineEpsilon * 10)] // value: (2 / sqrt(pi))
1807 [InlineData(1.41421356f, 1.18920712f, CrossPlatformMachineEpsilon * 10)] // value: (sqrt(2))
1808 [InlineData(1.44269504f, 1.20112241f, CrossPlatformMachineEpsilon * 10)] // value: (log2(e))
1809 [InlineData(1.57079633f, 1.25331414f, CrossPlatformMachineEpsilon * 10)] // value: (pi / 2)
1810 [InlineData(2.30258509f, 1.51742713f, CrossPlatformMachineEpsilon * 10)] // value: (ln(10))
1811 [InlineData(2.71828183f, 1.64872127f, CrossPlatformMachineEpsilon * 10)] // value: (e)
1812 [InlineData(3.14159265f, 1.77245385F, CrossPlatformMachineEpsilon * 10)] // value: (pi)
1813 [InlineData(float.PositiveInfinity, float.PositiveInfinity, 0.0f)]
1814 public static void Sqrt(float value, float expectedResult, float allowedVariance)
1816 AssertEqual(expectedResult, MathF.Sqrt(value), allowedVariance);
1820 [InlineData(float.NegativeInfinity, float.NaN, 0.0f)]
1821 [InlineData(-3.14159265f, -0.0f, CrossPlatformMachineEpsilon)] // value: -(pi)
1822 [InlineData(-2.71828183f, 0.450549534f, CrossPlatformMachineEpsilon)] // value: -(e)
1823 [InlineData(-2.30258509f, 1.11340715f, CrossPlatformMachineEpsilon * 10)] // value: -(ln(10))
1824 [InlineData(-1.57079633f, 22877332.0f, 10.0f)] // value: -(pi / 2)
1825 [InlineData(-1.44269504f, -7.76357567f, CrossPlatformMachineEpsilon * 10)] // value: -(log2(e))
1826 [InlineData(-1.41421356f, -6.33411917f, CrossPlatformMachineEpsilon * 10)] // value: -(sqrt(2))
1827 [InlineData(-1.12837917f, -2.11087684f, CrossPlatformMachineEpsilon * 10)] // value: -(2 / sqrt(pi))
1828 [InlineData(-1.0f, -1.55740772f, CrossPlatformMachineEpsilon * 10)]
1829 [InlineData(-0.785398163f, -1.0f, CrossPlatformMachineEpsilon * 10)] // value: -(pi / 4)
1830 [InlineData(-0.707106781f, -0.854510432f, CrossPlatformMachineEpsilon)] // value: -(1 / sqrt(2))
1831 [InlineData(-0.693147181f, -0.830640878f, CrossPlatformMachineEpsilon)] // value: -(ln(2))
1832 [InlineData(-0.636619772f, -0.739302950f, CrossPlatformMachineEpsilon)] // value: -(2 / pi)
1833 [InlineData(-0.434294482f, -0.463829067f, CrossPlatformMachineEpsilon)] // value: -(log10(e))
1834 [InlineData(-0.318309886f, -0.329514733f, CrossPlatformMachineEpsilon)] // value: -(1 / pi)
1835 [InlineData(-0.0f, -0.0f, 0.0f)]
1836 [InlineData(float.NaN, float.NaN, 0.0f)]
1837 [InlineData(0.0f, 0.0f, 0.0f)]
1838 [InlineData(0.318309886f, 0.329514733f, CrossPlatformMachineEpsilon)] // value: (1 / pi)
1839 [InlineData(0.434294482f, 0.463829067f, CrossPlatformMachineEpsilon)] // value: (log10(e))
1840 [InlineData(0.636619772f, 0.739302950f, CrossPlatformMachineEpsilon)] // value: (2 / pi)
1841 [InlineData(0.693147181f, 0.830640878f, CrossPlatformMachineEpsilon)] // value: (ln(2))
1842 [InlineData(0.707106781f, 0.854510432f, CrossPlatformMachineEpsilon)] // value: (1 / sqrt(2))
1843 [InlineData(0.785398163f, 1.0f, CrossPlatformMachineEpsilon * 10)] // value: (pi / 4)
1844 [InlineData(1.0f, 1.55740772f, CrossPlatformMachineEpsilon * 10)]
1845 [InlineData(1.12837917f, 2.11087684f, CrossPlatformMachineEpsilon * 10)] // value: (2 / sqrt(pi))
1846 [InlineData(1.41421356f, 6.33411917f, CrossPlatformMachineEpsilon * 10)] // value: (sqrt(2))
1847 [InlineData(1.44269504f, 7.76357567f, CrossPlatformMachineEpsilon * 10)] // value: (log2(e))
1848 [InlineData(1.57079633f, -22877332.0f, 10.0f)] // value: (pi / 2)
1849 [InlineData(2.30258509f, -1.11340715f, CrossPlatformMachineEpsilon * 10)] // value: (ln(10))
1850 [InlineData(2.71828183f, -0.450549534f, CrossPlatformMachineEpsilon)] // value: (e)
1851 [InlineData(3.14159265f, 0.0f, CrossPlatformMachineEpsilon)] // value: (pi)
1852 [InlineData(float.PositiveInfinity, float.NaN, 0.0f)]
1853 public static void Tan(float value, float expectedResult, float allowedVariance)
1855 AssertEqual(expectedResult, MathF.Tan(value), allowedVariance);
1859 [InlineData(float.NegativeInfinity, -1.0f, CrossPlatformMachineEpsilon * 10)]
1860 [InlineData(-3.14159265f, -0.996272076f, CrossPlatformMachineEpsilon)] // value: -(pi)
1861 [InlineData(-2.71828183f, -0.991328916f, CrossPlatformMachineEpsilon)] // value: -(e)
1862 [InlineData(-2.30258509f, -0.980198020f, CrossPlatformMachineEpsilon)] // value: -(ln(10))
1863 [InlineData(-1.57079633f, -0.917152336f, CrossPlatformMachineEpsilon)] // value: -(pi / 2)
1864 [InlineData(-1.44269504f, -0.894238946f, CrossPlatformMachineEpsilon)] // value: -(log2(e))
1865 [InlineData(-1.41421356f, -0.888385562f, CrossPlatformMachineEpsilon)] // value: -(sqrt(2))
1866 [InlineData(-1.12837917f, -0.810463806f, CrossPlatformMachineEpsilon)] // value: -(2 / sqrt(pi))
1867 [InlineData(-1.0f, -0.761594156f, CrossPlatformMachineEpsilon)]
1868 [InlineData(-0.785398163f, -0.655794203f, CrossPlatformMachineEpsilon)] // value: -(pi / 4)
1869 [InlineData(-0.707106781f, -0.608859365f, CrossPlatformMachineEpsilon)] // value: -(1 / sqrt(2))
1870 [InlineData(-0.693147181f, -0.6f, CrossPlatformMachineEpsilon)] // value: -(ln(2))
1871 [InlineData(-0.636619772f, -0.562593600f, CrossPlatformMachineEpsilon)] // value: -(2 / pi)
1872 [InlineData(-0.434294482f, -0.408904012f, CrossPlatformMachineEpsilon)] // value: -(log10(e))
1873 [InlineData(-0.318309886f, -0.307977913f, CrossPlatformMachineEpsilon)] // value: -(1 / pi)
1874 [InlineData(-0.0f, -0.0f, 0.0f)]
1875 [InlineData(float.NaN, float.NaN, 0.0f)]
1876 [InlineData(0.0f, 0.0f, 0.0f)]
1877 [InlineData(0.318309886f, 0.307977913f, CrossPlatformMachineEpsilon)] // value: (1 / pi)
1878 [InlineData(0.434294482f, 0.408904012f, CrossPlatformMachineEpsilon)] // value: (log10(e))
1879 [InlineData(0.636619772f, 0.562593600f, CrossPlatformMachineEpsilon)] // value: (2 / pi)
1880 [InlineData(0.693147181f, 0.6f, CrossPlatformMachineEpsilon)] // value: (ln(2))
1881 [InlineData(0.707106781f, 0.608859365f, CrossPlatformMachineEpsilon)] // value: (1 / sqrt(2))
1882 [InlineData(0.785398163f, 0.655794203f, CrossPlatformMachineEpsilon)] // value: (pi / 4)
1883 [InlineData(1.0f, 0.761594156f, CrossPlatformMachineEpsilon)]
1884 [InlineData(1.12837917f, 0.810463806f, CrossPlatformMachineEpsilon)] // value: (2 / sqrt(pi))
1885 [InlineData(1.41421356f, 0.888385562f, CrossPlatformMachineEpsilon)] // value: (sqrt(2))
1886 [InlineData(1.44269504f, 0.894238946f, CrossPlatformMachineEpsilon)] // value: (log2(e))
1887 [InlineData(1.57079633f, 0.917152336f, CrossPlatformMachineEpsilon)] // value: (pi / 2)
1888 [InlineData(2.30258509f, 0.980198020f, CrossPlatformMachineEpsilon)] // value: (ln(10))
1889 [InlineData(2.71828183f, 0.991328916f, CrossPlatformMachineEpsilon)] // value: (e)
1890 [InlineData(3.14159265f, 0.996272076f, CrossPlatformMachineEpsilon)] // value: (pi)
1891 [InlineData(float.PositiveInfinity, 1.0f, CrossPlatformMachineEpsilon * 10)]
1892 public static void Tanh(float value, float expectedResult, float allowedVariance)
1894 AssertEqual(expectedResult, MathF.Tanh(value), allowedVariance);
1898 public static void Truncate()
1900 Assert.Equal(0.0f, MathF.Truncate(0.12345f));
1901 Assert.Equal(3.0f, MathF.Truncate(3.14159f));
1902 Assert.Equal(-3.0f, MathF.Truncate(-3.14159f));