Merge pull request #1991 from esdrubal/seq_test_fix
[mono.git] / mcs / class / corlib / Test / System / MathTest.cs
1 // MathTest.cs
2 //
3 // Jon Guymon (guymon@slackworks.com)
4 // Pedro Martínez Juliá (yoros@wanadoo.es)
5 //
6 // (C) 2002 Jon Guymon
7 // Copyright (C) 2003 Pedro Martínez Juliá <yoros@wanadoo.es>
8 // Copyright (C) 2004 Novell (http://www.novell.com)
9 // 
10
11 using System;
12 using NUnit.Framework;
13
14 namespace MonoTests.System
15 {
16         [TestFixture]
17         public class MathTest
18         {
19                 private static double double_epsilon =
20                         double.Epsilon;
21
22                 static double x = 0.1234;
23                 static double y = 12.345;
24
25                 [Test]
26                 public void TestDecimalAbs ()
27                 {
28                         decimal a = -9.0M;
29
30                         Assert.IsTrue (9.0M == Math.Abs (a), "#1");
31                         Assert.IsTrue (Decimal.MaxValue == Math.Abs (Decimal.MaxValue), "#2");
32                         Assert.IsTrue (Decimal.MaxValue == Math.Abs (Decimal.MinValue), "#3");
33                         Assert.IsTrue (Decimal.Zero == Math.Abs (Decimal.Zero), "#4");
34                         Assert.IsTrue (Decimal.One == Math.Abs (Decimal.One), "#5");
35                         Assert.IsTrue (Decimal.One == Math.Abs (Decimal.MinusOne), "#6");
36                 }
37
38                 [Test]
39                 public void TestDoubleAbs ()
40                 {
41                         double a = -9.0D;
42
43                         Assert.IsTrue (9.0D == Math.Abs (a), "#1");
44                         Assert.IsTrue (0.0D == Math.Abs (0.0D), "#2");
45                         Assert.IsTrue (Double.MaxValue == Math.Abs (Double.MaxValue), "#3");
46                         Assert.IsTrue (Double.MaxValue == Math.Abs (Double.MinValue), "#4");
47                         Assert.IsTrue (Double.IsPositiveInfinity (Math.Abs (Double.PositiveInfinity)), "#5");
48                         Assert.IsTrue (Double.IsPositiveInfinity (Math.Abs (Double.NegativeInfinity)), "#6");
49                         Assert.IsTrue (Double.IsNaN (Math.Abs (Double.NaN)), "#7");
50                 }
51
52                 [Test]
53                 public void TestFloatAbs ()
54                 {
55                         float a = -9.0F;
56
57                         Assert.IsTrue (9.0F == Math.Abs (a), "#1");
58                         Assert.IsTrue (0.0F == Math.Abs (0.0F), "#2");
59                         Assert.IsTrue (Single.MaxValue == Math.Abs (Single.MaxValue), "#3");
60                         Assert.IsTrue (Single.MaxValue == Math.Abs (Single.MinValue), "#4");
61                         Assert.IsTrue (Single.PositiveInfinity == Math.Abs (Single.PositiveInfinity), "#5");
62                         Assert.IsTrue (Single.PositiveInfinity == Math.Abs (Single.NegativeInfinity), "#6");
63                         Assert.IsTrue (Single.IsNaN (Math.Abs (Single.NaN)), "#7");
64                 }
65
66                 [Test]
67                 public void TestLongAbs ()
68                 {
69                         long a = -9L;
70                         long b = Int64.MinValue;
71
72                         Assert.IsTrue (9L == Math.Abs (a), "#1");
73                         try {
74                                 Math.Abs (b);
75                                 Assert.Fail ("#2");
76                         } catch (Exception e) {
77                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#3");
78                         }
79                         Assert.IsTrue (Int64.MaxValue == Math.Abs (Int64.MaxValue), "#4");
80                 }
81
82                 [Test]
83                 public void TestIntAbs ()
84                 {
85                         int a = -9;
86                         int b = Int32.MinValue;
87
88                         Assert.IsTrue (9 == Math.Abs (a), "#1");
89                         try {
90                                 Math.Abs (b);
91                                 Assert.Fail ("#2");
92                         } catch (Exception e) {
93                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#3");
94                         }
95                         Assert.IsTrue (Int32.MaxValue == Math.Abs (Int32.MaxValue), "#4");
96                 }
97
98                 [Test]
99                 public void TestSbyteAbs ()
100                 {
101                         sbyte a = -9;
102                         sbyte b = SByte.MinValue;
103
104                         Assert.IsTrue (9 == Math.Abs (a), "#1");
105                         try {
106                                 Math.Abs (b);
107                                 Assert.Fail ("#2");
108                         } catch (Exception e) {
109                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#3");
110                         }
111                         Assert.IsTrue (SByte.MaxValue == Math.Abs (SByte.MaxValue), "#4");
112                 }
113
114                 [Test]
115                 public void TestShortAbs ()
116                 {
117                         short a = -9;
118                         short b = Int16.MinValue;
119
120                         Assert.IsTrue (9 == Math.Abs (a), "#1");
121                         try {
122                                 Math.Abs (b);
123                                 Assert.Fail ("#2");
124                         } catch (Exception e) {
125                                 Assert.AreEqual (typeof (OverflowException), e.GetType (), "#3");
126                         }
127                         Assert.IsTrue (Int16.MaxValue == Math.Abs (Int16.MaxValue), "#4");
128                 }
129
130                 [Test]
131                 public void TestAcos ()
132                 {
133                         double a = Math.Acos (x);
134                         double b = 1.4470809809523457;
135
136                         bool regularTest = (Math.Abs (a - b) <= double_epsilon);
137                         if (!regularTest){
138                                 //
139                                 // On MacOS X libc acos (0.1234) returns
140                                 // 1.4470809809523455 (hex 0x3ff7273e62fda9ab) instead
141                                 // of 1.4470809809523457 (hex 0x3ff7273e62fda9ac)
142                                 //
143                                 // For now, let it go
144                                 //
145                                 if (a == 1.4470809809523455)
146                                         regularTest = true;
147                         }
148                         
149                         Assert.IsTrue (regularTest, a.ToString ("G99") + " != " + b.ToString ("G99"));
150                         
151                         Assert.IsTrue (double.IsNaN (Math.Acos (-1.01D)));
152                         Assert.IsTrue (double.IsNaN (Math.Acos (1.01D)));
153                         Assert.IsTrue (double.IsNaN (Math.Acos (Double.MinValue)));
154                         Assert.IsTrue (double.IsNaN (Math.Acos (Double.MaxValue)));
155                         Assert.IsTrue (double.IsNaN (Math.Acos (Double.NegativeInfinity)));
156                         Assert.IsTrue (double.IsNaN (Math.Acos (Double.PositiveInfinity)));
157                 }
158
159                 [Test]
160                 public void TestAsin ()
161                 {
162                         double a = Math.Asin (x);
163                         double b = 0.12371534584255098;
164
165                         Assert.IsTrue ((Math.Abs (a - b) <= double_epsilon), a.ToString ("G99")
166                                 + " != " + b.ToString ("G99"));
167                         Assert.IsTrue (double.IsNaN (Math.Asin (-1.01D)));
168                         Assert.IsTrue (double.IsNaN (Math.Asin (1.01D)));
169                         Assert.IsTrue (double.IsNaN (Math.Asin (Double.MinValue)));
170                         Assert.IsTrue (double.IsNaN (Math.Asin (Double.MaxValue)));
171                         Assert.IsTrue (double.IsNaN (Math.Asin (Double.NegativeInfinity)));
172                         Assert.IsTrue (double.IsNaN (Math.Asin (Double.PositiveInfinity)));
173                 }
174
175                 [Test]
176                 public void TestAtan ()
177                 {
178                         double a = Math.Atan (x);
179                         double b = 0.12277930094473837;
180                         double c = 1.5707963267948966;
181                         double d = -1.5707963267948966;
182
183                         Assert.IsTrue ((Math.Abs (a - b) <= double_epsilon), "#1: " + a.ToString ("G99")
184                                 + " != " + b.ToString ("G99"));
185                         Assert.IsTrue (double.IsNaN (Math.Atan (double.NaN)), "should return NaN");
186                         Assert.IsTrue (Math.Abs ((double) Math.Atan (double.PositiveInfinity) - c) <= 0.0000000000000001,
187                                 "#2: " + Math.Atan (double.PositiveInfinity).ToString ("G99") + " != " + c.ToString ("G99"));
188                         Assert.IsTrue (Math.Abs ((double) Math.Atan (double.NegativeInfinity) - d) <= 0.0000000000000001,
189                                 "#3: " + Math.Atan (double.NegativeInfinity).ToString ("G99") + " != " + d.ToString ("G99"));
190                 }
191
192                 [Test]
193                 public void TestAtan2 ()
194                 {
195                         double a = Math.Atan2 (x, y);
196                         double b = 0.0099956168687207747;
197
198                         Assert.IsTrue ((Math.Abs (a - b) <= double_epsilon), a.ToString ("G99")
199                                 + " != " + b.ToString ("G99"));
200                         Assert.IsTrue (double.IsNaN (Math.Acos (-2D)));
201                         Assert.IsTrue (double.IsNaN (Math.Acos (2D)));
202                 }
203
204                 // The following test is for methods that are in ECMA but they are
205                 // not implemented in MS.NET. I leave them commented.
206                 /*
207                 public void TestBigMul () {
208                         int a = int.MaxValue;
209                         int b = int.MaxValue;
210
211                         Assert(((long)a * (long)b) == Math.BigMul(a,b));
212                 }
213                 */
214
215                 [Test]
216                 public void TestCos ()
217                 {
218                         double a = Math.Cos (x);
219                         double b = 0.99239587670489104;
220
221                         Assert.IsTrue ((Math.Abs (a - b) <= double_epsilon), a.ToString ("G99")
222                                 + " != " + b.ToString ("G99"));
223                         Assert.IsTrue (double.IsNaN (Math.Cos (Double.NaN)));
224                         Assert.IsTrue (double.IsNaN (Math.Cos (Double.NegativeInfinity)));
225                         Assert.IsTrue (double.IsNaN (Math.Cos (Double.PositiveInfinity)));
226                 }
227
228                 [Test]
229                 public void TestCosh ()
230                 {
231                         double a = Math.Cosh (x);
232                         double b = 1.0076234465130722;
233
234                         Assert.IsTrue ((Math.Abs (a - b) <= double_epsilon), a.ToString ("G99")
235                                 + " != " + b.ToString ("G99"));
236                         Assert.IsTrue (Math.Cosh (double.NegativeInfinity) == double.PositiveInfinity);
237                         Assert.IsTrue (Math.Cosh (double.PositiveInfinity) == double.PositiveInfinity);
238                         Assert.IsTrue (double.IsNaN (Math.Cosh (double.NaN)));
239                 }
240
241                 // The following test is for methods that are in ECMA but they are
242                 // not implemented in MS.NET. I leave them commented.
243                 /*
244                 public void TestIntDivRem () {
245                         int a = 5;
246                         int b = 2;
247                         int div = 0, rem = 0;
248
249                         div = Math.DivRem (a, b, out rem);
250
251                         Assert.IsTrue (rem == 1);
252                         Assert.IsTrue (div == 2);
253                 }
254
255                 public void TestLongDivRem () {
256                         long a = 5;
257                         long b = 2;
258                         long div = 0, rem = 0;
259
260                         div = Math.DivRem (a, b, out rem);
261
262                         Assert.IsTrue (rem == 1);
263                         Assert.IsTrue (div == 2);
264                 }
265                 */
266
267                 [Test]
268                 public void TestSin ()
269                 {
270                         double a = Math.Sin (x);
271                         double b = 0.12308705821137626;
272
273                         Assert.IsTrue ((Math.Abs (a - b) <= double_epsilon), a.ToString ("G99")
274                                 + " != " + b.ToString ("G99"));
275                         Assert.IsTrue (double.IsNaN (Math.Sin (Double.NaN)));
276                         Assert.IsTrue (double.IsNaN (Math.Sin (Double.NegativeInfinity)));
277                         Assert.IsTrue (double.IsNaN (Math.Sin (Double.PositiveInfinity)));
278                 }
279
280                 [Test]
281                 public void TestSinh ()
282                 {
283                         double a = Math.Sinh (x);
284                         double b = 0.12371341868561381;
285
286                         Assert.IsTrue (Math.Abs (a - b) <= 0.0000000000000001, a.ToString ("G99")
287                                 + " != " + b.ToString ("G99"));
288                         Assert.IsTrue (double.IsNaN (Math.Sinh (Double.NaN)));
289                         Assert.IsTrue (double.IsNegativeInfinity (Math.Sinh (Double.NegativeInfinity)));
290                         Assert.IsTrue (double.IsPositiveInfinity (Math.Sinh (Double.PositiveInfinity)));
291                 }
292
293                 [Test]
294                 public void TestTan ()
295                 {
296                         double a = Math.Tan (x);
297                         double b = 0.12403019913793806;
298
299                         Assert.IsTrue ((Math.Abs (a - b) <= double_epsilon), a.ToString ("G99")
300                                 + " != " + b.ToString ("G99"));
301                         Assert.IsTrue (Double.IsNaN (Math.Tan (Double.NaN)));
302                         Assert.IsTrue (Double.IsNaN (Math.Tan (Double.PositiveInfinity)));
303                         Assert.IsTrue (Double.IsNaN (Math.Tan (Double.NegativeInfinity)));
304                 }
305
306                 [Test]
307                 public void TestTanh ()
308                 {
309                         double a = Math.Tanh (x);
310                         double b = 0.12277743150353424;
311
312                         Assert.IsTrue ((Math.Abs (a - b) <= double_epsilon), a.ToString ("G99")
313                                 + " != " + b.ToString ("G99"));
314                         Assert.IsTrue (Double.IsNaN (Math.Tanh (Double.NaN)),
315                                 "Tanh(NaN) should be NaN");
316                         Assert.IsTrue (1 == Math.Tanh (Double.PositiveInfinity),
317                                 "Tanh(+Infinity) should be 1");
318                         Assert.IsTrue (-1 == Math.Tanh (Double.NegativeInfinity),
319                                 "Tanh(-Infinity) should be -1");
320                 }
321
322                 [Test]
323                 public void TestSqrt ()
324                 {
325                         double a = Math.Sqrt (x);
326                         double b = 0.35128336140500593;
327
328                         Assert.IsTrue ((Math.Abs (a - b) <= double_epsilon), a.ToString ("G99")
329                                 + " != " + b.ToString ("G99"));
330                         Assert.IsTrue (Double.IsNaN (Math.Sqrt (Double.NaN)));
331                         Assert.IsTrue (Double.IsPositiveInfinity (Math.Sqrt (Double.PositiveInfinity)));
332                         Assert.IsTrue (Double.IsNaN (Math.Sqrt (Double.NegativeInfinity)));
333                 }
334
335                 [Test]
336                 public void TestExp ()
337                 {
338                         double a = Math.Exp (x);
339                         double b = 1.1313368651986859;
340
341                         Assert.IsTrue ((Math.Abs (a - b) <= double_epsilon), a.ToString ("G99")
342                                 + " != " + b.ToString ("G99"));
343                         Assert.IsTrue (double.IsNaN (Math.Exp (double.NaN)));
344                         Assert.IsTrue (Math.Exp (double.NegativeInfinity) == 0);
345                         Assert.IsTrue (Math.Exp (double.PositiveInfinity) == double.PositiveInfinity);
346                 }
347
348                 [Test]
349                 public void TestCeiling ()
350                 {
351                         int iTest = 1;
352                         try {
353                                 double a = Math.Ceiling (1.5);
354                                 double b = 2;
355
356                                 iTest++;
357                                 Assert.IsTrue ((Math.Abs (a - b) <= double_epsilon), a.ToString ("G99")
358                                         + " != " + b.ToString ("G99"));
359                                 iTest++;
360                                 Assert.IsTrue (Math.Ceiling (double.NegativeInfinity) == double.NegativeInfinity);
361                                 iTest++;
362                                 Assert.IsTrue (Math.Ceiling (double.PositiveInfinity) == double.PositiveInfinity);
363                                 iTest++;
364                                 Assert.IsTrue (double.IsNaN (Math.Ceiling (double.NaN)));
365
366                                 iTest++;
367                                 Assert.IsTrue (Double.MaxValue == Math.Ceiling (Double.MaxValue));
368
369                                 iTest++;
370                                 Assert.IsTrue (Double.MinValue == Math.Ceiling (Double.MinValue));
371                         } catch (Exception e) {
372                                 Assert.Fail ("Unexpected Exception at iTest=" + iTest + ": " + e);
373                         }
374                 }
375
376                 [Test]
377                 public void TestDecimalCeiling()
378                 {
379                         decimal a = Math.Ceiling(1.5M);
380                         decimal b = 2M;
381
382                         Assert.IsTrue (a == b, "#1");
383                         Assert.IsTrue (Decimal.MaxValue == Math.Ceiling(Decimal.MaxValue), "#2");
384                         Assert.IsTrue (Decimal.MinValue == Math.Ceiling(Decimal.MinValue), "#3");
385                 }
386
387                 [Test]
388                 public void TestFloor ()
389                 {
390                         double a = Math.Floor (1.5);
391                         double b = 1;
392
393                         Assert.IsTrue ((Math.Abs (a - b) <= double_epsilon), a.ToString ("G99")
394                                 + " != " + b.ToString ("G99"));
395                         Assert.IsTrue (Math.Floor (double.NegativeInfinity) == double.NegativeInfinity);
396                         Assert.IsTrue (Math.Floor (double.PositiveInfinity) == double.PositiveInfinity);
397                         Assert.IsTrue (double.IsNaN (Math.Floor (double.NaN)));
398
399                         Assert.IsTrue (Double.MaxValue == Math.Floor (Double.MaxValue));
400
401                         Assert.IsTrue (Double.MinValue == Math.Floor (Double.MinValue));
402                 }
403
404                 [Test]
405                 public void TestIEEERemainder ()
406                 {
407                         double a = Math.IEEERemainder (y, x);
408                         double b = 0.0050000000000010592;
409
410                         Assert.IsTrue ((Math.Abs (a - b) <= double_epsilon), a.ToString ("G99")
411                                 + " != " + b.ToString ("G99"));
412
413                         Assert.IsTrue (double.IsNaN (Math.IEEERemainder (y, 0)), "Positive 0");
414
415                         // http://www.obtuse.com/resources/negative_zero.html
416                         double n0 = BitConverter.Int64BitsToDouble (Int64.MinValue);
417                         Assert.IsTrue (double.IsNaN (Math.IEEERemainder (n0, 0)), "Negative 0");
418
419                         // the "zero" remainder of negative number is negative
420                         long result = BitConverter.DoubleToInt64Bits (Math.IEEERemainder (-1, 1));
421                         Assert.AreEqual (Int64.MinValue, result, "Negative Dividend");
422                 }
423
424                 [Test]
425                 public void TestLog ()
426                 {
427                         double a = Math.Log (y);
428                         double b = 2.513251122797143;
429
430                         Assert.IsTrue ((Math.Abs (a - b) <= double_epsilon), a.ToString ("G99")
431                                 + " != " + b.ToString ("G99"));
432                         Assert.IsTrue (double.IsNaN (Math.Log (-1)));
433                         Assert.IsTrue (double.IsNaN (Math.Log (double.NaN)));
434
435                         // MS docs say this should be PositiveInfinity
436                         Assert.IsTrue (Math.Log (0) == double.NegativeInfinity);
437                         Assert.IsTrue (Math.Log (double.PositiveInfinity) == double.PositiveInfinity);
438                 }
439
440                 [Test]
441                 public void TestLog2 ()
442                 {
443                         double a = Math.Log (x, y);
444                         double b = -0.83251695325303621;
445
446                         Assert.IsTrue ((Math.Abs (a - b) <= 1e-14), a + " != " + b
447                                 + " because diff is " + Math.Abs (a - b));
448                         Assert.IsTrue (double.IsNaN (Math.Log (-1, y)));
449                         Assert.IsTrue (double.IsNaN (Math.Log (double.NaN, y)));
450                         Assert.IsTrue (double.IsNaN (Math.Log (x, double.NaN)));
451                         Assert.IsTrue (double.IsNaN (Math.Log (double.NegativeInfinity, y)));
452                         Assert.IsTrue (double.IsNaN (Math.Log (x, double.NegativeInfinity)));
453                         Assert.IsTrue (double.IsNaN (Math.Log (double.PositiveInfinity, double.PositiveInfinity)));
454                         Assert.IsTrue (double.IsNaN (Math.Log (2, 1)));
455
456                         // MS docs say this should be PositiveInfinity
457                         Assert.IsTrue (Math.Log (0, y) == double.NegativeInfinity);
458                         Assert.IsTrue (Math.Log (double.PositiveInfinity, y) == double.PositiveInfinity);
459
460                         Assert.IsTrue (Double.IsNaN (Math.Log (x, double.PositiveInfinity)));
461                 }
462
463                 [Test]
464                 public void TestLog10 ()
465                 {
466                         double a = Math.Log10 (x);
467                         double b = -0.90868484030277719;
468
469                         Assert.IsTrue ((Math.Abs (a - b) <= double_epsilon), a.ToString ("G99")
470                                 + " != " + b.ToString ("G99"));
471                         Assert.IsTrue (double.IsNaN (Math.Log10 (-1)));
472                         Assert.IsTrue (double.IsNaN (Math.Log10 (double.NaN)));
473
474                         // MS docs say this should be PositiveInfinity
475                         Assert.IsTrue (Math.Log10 (0) == double.NegativeInfinity);
476                         Assert.IsTrue (Math.Log10 (double.PositiveInfinity) == double.PositiveInfinity);
477
478                 }
479
480                 [Test]
481                 public void TestPow ()
482                 {
483                         double precision;
484                         int iTest = 1;
485 #if MONODROID
486                         // It fails on Nexus 9 with
487                         //
488                         //   1.3636094460602122 != 1.3636094460602119
489                         //
490                         // when using double_epsilon. Precision differs between different ARM CPUs, so we
491                         // will just use a more conservative value
492                         precision = double_epsilon * 10;
493 #else
494                         precision = double_epsilon;
495 #endif
496
497                         /* documentation cases : https://msdn.microsoft.com/en-us/library/system.math.pow%28v=vs.110%29.aspx */
498
499                         /* x or y = NaN -> NaN */
500                         Assert.IsTrue (double.IsNaN (Math.Pow (             double.NaN,              double.NaN)), "#1");
501                         Assert.IsTrue (double.IsNaN (Math.Pow (             double.NaN, double.NegativeInfinity)), "#2");
502                         Assert.IsTrue (double.IsNaN (Math.Pow (             double.NaN,                      -2)), "#2");
503                         Assert.IsTrue (double.IsNaN (Math.Pow (             double.NaN,                      -1)), "#3");
504                         Assert.IsTrue (double.IsNaN (Math.Pow (             double.NaN,                       0)), "#4");
505                         Assert.IsTrue (double.IsNaN (Math.Pow (             double.NaN,                       1)), "#5");
506                         Assert.IsTrue (double.IsNaN (Math.Pow (             double.NaN,                       2)), "#6");
507                         Assert.IsTrue (double.IsNaN (Math.Pow (             double.NaN, double.PositiveInfinity)), "#7");
508                         Assert.IsTrue (double.IsNaN (Math.Pow (double.NegativeInfinity,              double.NaN)), "#8");
509                         Assert.IsTrue (double.IsNaN (Math.Pow (                     -2,              double.NaN)), "#9");
510                         Assert.IsTrue (double.IsNaN (Math.Pow (                     -1,              double.NaN)), "#10");
511                         Assert.IsTrue (double.IsNaN (Math.Pow (                      0,              double.NaN)), "#11");
512                         Assert.IsTrue (double.IsNaN (Math.Pow (                      1,              double.NaN)), "#12");
513                         Assert.IsTrue (double.IsNaN (Math.Pow (                      2,              double.NaN)), "#13");
514                         Assert.IsTrue (double.IsNaN (Math.Pow (double.PositiveInfinity,              double.NaN)), "#14");
515
516                         /* x = Any value except NaN; y = 0 -> 1 */
517                         Assert.AreEqual ((double) 1, Math.Pow (2, 0), "#15");
518
519                         /* x = NegativeInfinity; y < 0 -> 0 */
520                         Assert.AreEqual ((double) 0, Math.Pow (double.NegativeInfinity, -2), "#16");
521
522                         /* x = NegativeInfinity; y is a positive odd integer -> NegativeInfinity */
523                         Assert.AreEqual (double.NegativeInfinity, Math.Pow (double.NegativeInfinity, 3), "#17");
524
525                         /* x = NegativeInfinity; y is positive but not an odd integer -> PositiveInfinity */
526                         Assert.AreEqual (double.PositiveInfinity, Math.Pow (double.NegativeInfinity, 2), "#18");
527
528                         /* x < 0 but not NegativeInfinity; y is not an integer, NegativeInfinity, or PositiveInfinity -> NaN */
529                         Assert.IsTrue (double.IsNaN (Math.Pow (-1, 2.5)), "#19");
530
531                         /* x = -1; y = NegativeInfinity or PositiveInfinity -> NaN */
532                         Assert.IsTrue (double.IsNaN (Math.Pow (-1, double.PositiveInfinity)), "#20");
533                         Assert.IsTrue (double.IsNaN (Math.Pow (-1, double.NegativeInfinity)), "#21");
534
535                         /* -1 < x < 1; y = NegativeInfinity -> PositiveInfinity */
536                         Assert.AreEqual (double.PositiveInfinity, Math.Pow (-0.5, double.NegativeInfinity), "#22");
537                         Assert.AreEqual (double.PositiveInfinity, Math.Pow (+0.5, double.NegativeInfinity), "#23");
538
539                         /* -1 < x < 1; y = PositiveInfinity -> 0 */
540                         Assert.AreEqual ((double) 0, Math.Pow (-0.5, double.PositiveInfinity), "#24");
541                         Assert.AreEqual ((double) 0, Math.Pow (+0.5, double.PositiveInfinity), "#25");
542
543                         /* x < -1 or x > 1; y = NegativeInfinity -> 0 */
544                         Assert.AreEqual ((double) 0, Math.Pow (-2, double.NegativeInfinity), "#26");
545                         Assert.AreEqual ((double) 0, Math.Pow (+2, double.NegativeInfinity), "#27");
546
547                         /* x < -1 or x > 1; y = PositiveInfinity -> PositiveInfinity */
548                         Assert.AreEqual (double.PositiveInfinity, Math.Pow (-2, double.PositiveInfinity), "#28");
549                         Assert.AreEqual (double.PositiveInfinity, Math.Pow (+2, double.PositiveInfinity), "#29");
550
551                         /* x = 0; y < 0 -> PositiveInfinity */
552                         Assert.AreEqual (double.PositiveInfinity, Math.Pow (0, -2), "#30");
553
554                         /* x = 0; y > 0 -> PositiveInfinity */
555                         Assert.AreEqual ((double) 0, Math.Pow (0, +2), "#31");
556
557                         /* x = 1; y is any value except NaN -> 1 */
558                         Assert.AreEqual ((double) 1, Math.Pow (1, double.NegativeInfinity), "#32");
559                         Assert.AreEqual ((double) 1, Math.Pow (1,                      -2), "#33");
560                         Assert.AreEqual ((double) 1, Math.Pow (1,                       0), "#34");
561                         Assert.AreEqual ((double) 1, Math.Pow (1,                      +2), "#35");
562                         Assert.AreEqual ((double) 1, Math.Pow (1, double.PositiveInfinity), "#36");
563
564                         /* x = PositiveInfinity; y < 0 -> 0 */
565                         Assert.AreEqual ((double) 0, Math.Pow (double.PositiveInfinity, -1), "#37");
566                         Assert.AreEqual ((double) 0, Math.Pow (double.PositiveInfinity, -2), "#38");
567
568                         /* x = PositiveInfinity; y > 0 -> PositiveInfinity */
569                         Assert.AreEqual (double.PositiveInfinity, Math.Pow (double.PositiveInfinity, 1), "#39");
570                         Assert.AreEqual (double.PositiveInfinity, Math.Pow (double.PositiveInfinity, 2), "#40");
571
572                         /* other cases */
573
574                         double a = Math.Pow (y, x);
575                         double b = 1.363609446060212;
576
577                         Assert.IsTrue (Math.Abs (a - b) <= precision, "#41 " + a.ToString ("G99") + " != " + b.ToString ("G99") + " +/- " + precision.ToString ("G99"));
578                         Assert.AreEqual (double.NegativeInfinity, Math.Pow (double.NegativeInfinity, 1), "#42");
579                         Assert.AreEqual (double.PositiveInfinity, Math.Pow (double.NegativeInfinity, 2), "#43");
580
581                         Assert.AreEqual (Math.Pow (double.PositiveInfinity, double.NegativeInfinity), (double) 0, "#44");
582
583                         Assert.AreEqual ((double) 1, Math.Pow (-1, Double.MaxValue), "#45");
584                         Assert.AreEqual ((double) 1, Math.Pow (-1, Double.MinValue), "#46");
585                         Assert.AreEqual ((double) 0, Math.Pow (Double.MinValue, Double.MinValue), "#47");
586                         Assert.AreEqual (double.PositiveInfinity, Math.Pow (Double.MinValue, Double.MaxValue), "#48");
587
588                         double infinity = double.PositiveInfinity;
589                         Assert.AreEqual ((double) 0, Math.Pow (      0.5,  infinity), "#49");
590                         Assert.AreEqual (  infinity, Math.Pow (      0.5, -infinity), "#50");
591                         Assert.AreEqual (  infinity, Math.Pow (        2,  infinity), "#51");
592                         Assert.AreEqual ((double) 0, Math.Pow (        2, -infinity), "#52");
593                         Assert.AreEqual ((double) 1, Math.Pow ( infinity,         0), "#53");
594                         Assert.AreEqual ((double) 1, Math.Pow (-infinity,         0), "#54");
595                 }
596
597                 [Test]
598                 public void TestByteMax ()
599                 {
600                         byte a = 1;
601                         byte b = 2;
602
603                         Assert.IsTrue (b == Math.Max (a, b), "#1");
604                         Assert.IsTrue (b == Math.Max (b, a), "#2");
605                 }
606
607                 [Test]
608                 public void TestDecimalMax ()
609                 {
610                         decimal a = 1.5M;
611                         decimal b = 2.5M;
612
613                         Assert.IsTrue (b == Math.Max (a, b), "#1");
614                         Assert.IsTrue (b == Math.Max (b, a), "#2");
615                 }
616
617                 [Test]
618                 public void TestDoubleMax ()
619                 {
620                         double a = 1.5D;
621                         double b = 2.5D;
622
623                         Assert.IsTrue (b == Math.Max (a, b), "#1");
624                         Assert.IsTrue (b == Math.Max (b, a), "#2");
625
626                         Assert.IsTrue (Double.IsNaN (Math.Max (Double.NaN, Double.NaN)), "#3");
627                         Assert.IsTrue (Double.IsNaN (Math.Max (Double.NaN, a)), "#4");
628                         Assert.IsTrue (Double.IsNaN (Math.Max (b, Double.NaN)), "#5");
629                 }
630
631                 [Test]
632                 public void TestFloatMax ()
633                 {
634                         float a = 1.5F;
635                         float b = 2.5F;
636
637                         Assert.IsTrue (b == Math.Max (a, b), "#1");
638                         Assert.IsTrue (b == Math.Max (b, a), "#2");
639                         Assert.IsTrue (Single.IsNaN (Math.Max (Single.NaN, Single.NaN)), "#3");
640                         Assert.IsTrue (Single.IsNaN (Math.Max (Single.NaN, a)), "#4");
641                         Assert.IsTrue (Single.IsNaN (Math.Max (b, Single.NaN)), "#5");
642                 }
643
644                 [Test]
645                 public void TestIntMax ()
646                 {
647                         int a = 1;
648                         int b = 2;
649                         int c = 100;
650                         int d = -2147483647;
651
652                         Assert.AreEqual (b, Math.Max (a, b), "#1");
653                         Assert.AreEqual (b, Math.Max (b, a), "#2");
654                         Assert.AreEqual (c, Math.Max (c, d), "#3");
655                         Assert.AreEqual (c, Math.Max (d, c), "#4");
656                 }
657
658                 [Test]
659                 public void TestLongMax ()
660                 {
661                         long a = 1L;
662                         long b = 2L;
663
664                         Assert.IsTrue (b == Math.Max (a, b), "#1");
665                         Assert.IsTrue (b == Math.Max (b, a), "#2");
666                 }
667
668                 [Test]
669                 public void TestSbyteMax ()
670                 {
671                         sbyte a = 1;
672                         sbyte b = 2;
673
674                         Assert.IsTrue (b == Math.Max (a, b), "#1");
675                         Assert.IsTrue (b == Math.Max (b, a), "#2");
676                 }
677
678                 [Test]
679                 public void TestShortMax ()
680                 {
681                         short a = 1;
682                         short b = 2;
683
684                         Assert.IsTrue (b == Math.Max (a, b), "#1");
685                         Assert.IsTrue (b == Math.Max (b, a), "#2");
686                 }
687
688                 [Test]
689                 public void TestUintMax ()
690                 {
691                         uint a = 1U;
692                         uint b = 2U;
693
694                         Assert.IsTrue (b == Math.Max (a, b), "#1");
695                         Assert.IsTrue (b == Math.Max (b, a), "#2");
696                 }
697
698                 [Test]
699                 public void TestUlongMax ()
700                 {
701                         ulong a = 1UL;
702                         ulong b = 2UL;
703
704                         Assert.IsTrue (b == Math.Max (a, b), "#1");
705                         Assert.IsTrue (b == Math.Max (b, a), "#2");
706                 }
707
708                 [Test]
709                 public void TestUshortMax ()
710                 {
711                         ushort a = 1;
712                         ushort b = 2;
713
714                         Assert.IsTrue (b == Math.Max (a, b), "#1");
715                         Assert.IsTrue (b == Math.Max (b, a), "#2");
716                 }
717
718                 [Test]
719                 public void TestByteMin ()
720                 {
721                         byte a = 1;
722                         byte b = 2;
723
724                         Assert.IsTrue (a == Math.Min (a, b), "#1");
725                         Assert.IsTrue (a == Math.Min (b, a), "#2");
726                 }
727
728                 [Test]
729                 public void TestDecimalMin ()
730                 {
731                         decimal a = 1.5M;
732                         decimal b = 2.5M;
733
734                         Assert.IsTrue (a == Math.Min (a, b), "#1");
735                         Assert.IsTrue (a == Math.Min (b, a), "#2");
736                 }
737
738                 [Test]
739                 public void TestDoubleMin ()
740                 {
741                         double a = 1.5D;
742                         double b = 2.5D;
743
744                         Assert.IsTrue (a == Math.Min (a, b), "#1");
745                         Assert.IsTrue (a == Math.Min (b, a), "#2");
746                         Assert.IsTrue (Double.IsNaN (Math.Min (Double.NaN, Double.NaN)), "#3");
747                         Assert.IsTrue (Double.IsNaN (Math.Min (Double.NaN, a)), "#4");
748                         Assert.IsTrue (Double.IsNaN (Math.Min (b, Double.NaN)), "#5");
749                 }
750
751                 [Test]
752                 public void TestFloatMin ()
753                 {
754                         float a = 1.5F;
755                         float b = 2.5F;
756
757                         Assert.IsTrue (a == Math.Min (a, b), "#1");
758                         Assert.IsTrue (a == Math.Min (b, a), "#2");
759                         Assert.IsTrue (Single.IsNaN (Math.Min (Single.NaN, Single.NaN)), "#3");
760                         Assert.IsTrue (Single.IsNaN (Math.Min (Single.NaN, a)), "#4");
761                         Assert.IsTrue (Single.IsNaN (Math.Min (b, Single.NaN)), "#5");
762                 }
763
764                 [Test]
765                 public void TestIntMin ()
766                 {
767                         int a = 1;
768                         int b = 2;
769
770                         Assert.IsTrue (a == Math.Min (a, b), "#1");
771                         Assert.IsTrue (a == Math.Min (b, a), "#2");
772                 }
773
774                 [Test]
775                 public void TestLongMin ()
776                 {
777                         long a = 1L;
778                         long b = 2L;
779
780                         Assert.IsTrue (a == Math.Min (a, b), "#1");
781                         Assert.IsTrue (a == Math.Min (b, a), "#2");
782                 }
783
784                 [Test]
785                 public void TestSbyteMin ()
786                 {
787                         sbyte a = 1;
788                         sbyte b = 2;
789
790                         Assert.IsTrue (a == Math.Min (a, b), "#1");
791                         Assert.IsTrue (a == Math.Min (b, a), "#2");
792                 }
793
794                 [Test]
795                 public void TestShortMin ()
796                 {
797                         short a = 1;
798                         short b = 2;
799
800                         Assert.IsTrue (a == Math.Min (a, b), "#1");
801                         Assert.IsTrue (a == Math.Min (b, a), "#2");
802                 }
803
804                 [Test]
805                 public void TestUintMin ()
806                 {
807                         uint a = 1U;
808                         uint b = 2U;
809
810                         Assert.IsTrue (a == Math.Min (a, b), "#1");
811                         Assert.IsTrue (a == Math.Min (b, a), "#2");
812                 }
813
814                 [Test]
815                 public void TestUlongMin ()
816                 {
817                         ulong a = 1UL;
818                         ulong b = 2UL;
819
820                         Assert.IsTrue (a == Math.Min (a, b), "#1");
821                         Assert.IsTrue (a == Math.Min (b, a), "#2");
822                 }
823
824                 [Test]
825                 public void TestUshortMin ()
826                 {
827                         ushort a = 1;
828                         ushort b = 2;
829
830                         Assert.IsTrue (a == Math.Min (a, b), "#1");
831                         Assert.IsTrue (a == Math.Min (b, a), "#2");
832                 }
833
834                 [Test]
835                 public void TestDecimalRound ()
836                 {
837                         decimal a = 1.5M;
838                         decimal b = 2.5M;
839
840                         Assert.IsTrue (Math.Round (a) == 2, "#1");
841                         Assert.IsTrue (Math.Round (b) == 2, "#2");
842                         Assert.IsTrue (Decimal.MaxValue == Math.Round (Decimal.MaxValue), "#3");
843                         Assert.IsTrue (Decimal.MinValue == Math.Round (Decimal.MinValue), "#4");
844                 }
845
846                 [Test]
847                 public void TestDecimalRound2 ()
848                 {
849                         decimal a = 3.45M;
850                         decimal b = 3.46M;
851
852                         Assert.AreEqual (3.4M, Math.Round (a, 1), "#1");
853                         Assert.AreEqual (3.5M, Math.Round (b, 1), "#2");
854                 }
855
856                 [Test]
857                 public void TestDoubleRound ()
858                 {
859                         double a = 1.5D;
860                         double b = 2.5D;
861
862                         Assert.AreEqual (2D, Math.Round (a), "#1");
863                         Assert.AreEqual (2D, Math.Round (b), "#2");
864                         Assert.IsTrue (Double.MaxValue == Math.Round (Double.MaxValue), "#3");
865                         Assert.IsTrue (Double.MinValue == Math.Round (Double.MinValue), "#4");
866                 }
867
868                 [Test]
869                 public void TestDoubleTruncate ()
870                 {
871                         double a = 1.2D;
872                         double b = 2.8D;
873                         double c = 0D;
874
875                         Assert.AreEqual (1D, Math.Truncate (a), "#1");
876                         Assert.AreEqual (2D, Math.Truncate (b), "#2");
877
878                         Assert.AreEqual (-1D, Math.Truncate (a * -1D), "#3");
879                         Assert.AreEqual (-2D, Math.Truncate (b * -1D), "#4");
880
881                         Assert.AreEqual (0D, Math.Truncate (c), "#5");
882
883                         Assert.IsTrue (Double.MaxValue == Math.Truncate (Double.MaxValue), "#6");
884                         Assert.IsTrue (Double.MinValue == Math.Truncate (Double.MinValue), "#7");
885                 }
886
887                 [Test]
888                 public void TestDecimalTruncate ()
889                 {
890                         decimal a = 1.2M;
891                         decimal b = 2.8M;
892                         decimal c = 0M;
893
894                         Assert.AreEqual (1M, Math.Truncate (a), "#1");
895                         Assert.AreEqual (2M, Math.Truncate (b), "#2");
896
897                         Assert.AreEqual (-1M, Math.Truncate (a * -1M), "#3");
898                         Assert.AreEqual (-2M, Math.Truncate (b * -1M), "#4");
899
900                         Assert.AreEqual (0M, Math.Truncate (c), "#5");
901
902                         Assert.IsTrue (Decimal.MaxValue == Math.Truncate (Decimal.MaxValue), "#6");
903                         Assert.IsTrue (Decimal.MinValue == Math.Truncate (Decimal.MinValue), "#7");
904                 }
905
906                 [Test]
907                 public void TestDoubleRound2 ()
908                 {
909                         double a = 3.45D;
910                         double b = 3.46D;
911
912                         Assert.AreEqual (3.4D, Math.Round (a, 1), "#1");
913                         Assert.AreEqual (3.5D, Math.Round (b, 1), "#2");
914                         Assert.AreEqual (-0.1, Math.Round (-0.123456789, 1), "#3");
915                 }
916
917                 [Test]
918                 public void TestDoubleRound3 ()
919                 {
920                         Assert.AreEqual (1D, Math.Round (1D, 0, MidpointRounding.ToEven), "#1");
921                         Assert.AreEqual (1D, Math.Round (1D, 0, MidpointRounding.AwayFromZero), "#2");
922
923                         Assert.AreEqual (-1D, Math.Round (-1D, 0, MidpointRounding.ToEven), "#3");
924                         Assert.AreEqual (-1D, Math.Round (-1D, 0, MidpointRounding.AwayFromZero), "#4");
925
926                         Assert.AreEqual (1D, Math.Round (1D, 1, MidpointRounding.ToEven), "#5");
927                         Assert.AreEqual (1D, Math.Round (1D, 1, MidpointRounding.AwayFromZero), "#6");
928
929                         Assert.AreEqual (-1D, Math.Round (-1D, 1, MidpointRounding.ToEven), "#7");
930                         Assert.AreEqual (-1D, Math.Round (-1D, 1, MidpointRounding.AwayFromZero), "#8");
931
932                         Assert.AreEqual (1D, Math.Round (1.2345D, 0, MidpointRounding.ToEven), "#9");
933                         Assert.AreEqual (1D, Math.Round (1.2345D, 0, MidpointRounding.AwayFromZero), "#A");
934
935                         Assert.AreEqual (-1D, Math.Round (-1.2345D, 0, MidpointRounding.ToEven), "#B");
936                         Assert.AreEqual (-1D, Math.Round (-1.2345D, 0, MidpointRounding.AwayFromZero), "#C");
937
938                         Assert.AreEqual (1.2D, Math.Round (1.2345D, 1, MidpointRounding.ToEven), "#D");
939                         Assert.AreEqual (1.2D, Math.Round (1.2345D, 1, MidpointRounding.AwayFromZero), "#E");
940
941                         Assert.AreEqual (-1.2D, Math.Round (-1.2345D, 1, MidpointRounding.ToEven), "#F");
942                         Assert.AreEqual (-1.2D, Math.Round (-1.2345D, 1, MidpointRounding.AwayFromZero), "#10");
943
944                         Assert.AreEqual (1.23D, Math.Round (1.2345D, 2, MidpointRounding.ToEven), "#11");
945                         Assert.AreEqual (1.23D, Math.Round (1.2345D, 2, MidpointRounding.AwayFromZero), "#12");
946
947                         Assert.AreEqual (-1.23D, Math.Round (-1.2345D, 2, MidpointRounding.ToEven), "#13");
948                         Assert.AreEqual (-1.23D, Math.Round (-1.2345D, 2, MidpointRounding.AwayFromZero), "#14");
949
950                         Assert.AreEqual (1.234D, Math.Round (1.2345D, 3, MidpointRounding.ToEven), "#15");
951                         Assert.AreEqual (1.235D, Math.Round (1.2345D, 3, MidpointRounding.AwayFromZero), "#16");
952
953                         Assert.AreEqual (-1.234D, Math.Round (-1.2345D, 3, MidpointRounding.ToEven), "#17");
954                         Assert.AreEqual (-1.235D, Math.Round (-1.2345D, 3, MidpointRounding.AwayFromZero), "#18");
955
956                         Assert.AreEqual (1.2345D, Math.Round (1.2345D, 4, MidpointRounding.ToEven), "#19");
957                         Assert.AreEqual (1.2345D, Math.Round (1.2345D, 4, MidpointRounding.AwayFromZero), "#1A");
958
959                         Assert.AreEqual (-1.2345D, Math.Round (-1.2345D, 4, MidpointRounding.ToEven), "#1B");
960                         Assert.AreEqual (-1.2345D, Math.Round (-1.2345D, 4, MidpointRounding.AwayFromZero), "#1C");
961
962                         Assert.AreEqual (2D, Math.Round (1.5432D, 0, MidpointRounding.ToEven), "#1D");
963                         Assert.AreEqual (2D, Math.Round (1.5432D, 0, MidpointRounding.AwayFromZero), "#1E");
964
965                         Assert.AreEqual (-2D, Math.Round (-1.5432D, 0, MidpointRounding.ToEven), "#1F");
966                         Assert.AreEqual (-2D, Math.Round (-1.5432D, 0, MidpointRounding.AwayFromZero), "#20");
967
968                         Assert.AreEqual (1.5D, Math.Round (1.5432D, 1, MidpointRounding.ToEven), "#21");
969                         Assert.AreEqual (1.5D, Math.Round (1.5432D, 1, MidpointRounding.AwayFromZero), "#22");
970
971                         Assert.AreEqual (-1.5D, Math.Round (-1.5432D, 1, MidpointRounding.ToEven), "#23");
972                         Assert.AreEqual (-1.5D, Math.Round (-1.5432D, 1, MidpointRounding.AwayFromZero), "#24");
973
974                         Assert.AreEqual (1.54D, Math.Round (1.5432D, 2, MidpointRounding.ToEven), "#25");
975                         Assert.AreEqual (1.54D, Math.Round (1.5432D, 2, MidpointRounding.AwayFromZero), "#26");
976
977                         Assert.AreEqual (-1.54D, Math.Round (-1.5432D, 2, MidpointRounding.ToEven), "#27");
978                         Assert.AreEqual (-1.54D, Math.Round (-1.5432D, 2, MidpointRounding.AwayFromZero), "#28");
979
980                         Assert.AreEqual (1.543D, Math.Round (1.5432D, 3, MidpointRounding.ToEven), "#29");
981                         Assert.AreEqual (1.543D, Math.Round (1.5432D, 3, MidpointRounding.AwayFromZero), "#2A");
982
983                         Assert.AreEqual (-1.543D, Math.Round (-1.5432D, 3, MidpointRounding.ToEven), "#2B");
984                         Assert.AreEqual (-1.543D, Math.Round (-1.5432D, 3, MidpointRounding.AwayFromZero), "#2C");
985
986                         Assert.AreEqual (1.5432D, Math.Round (1.5432D, 4, MidpointRounding.ToEven), "#2D");
987                         Assert.AreEqual (1.5432D, Math.Round (1.5432D, 4, MidpointRounding.AwayFromZero), "#2E");
988
989                         Assert.AreEqual (-1.5432D, Math.Round (-1.5432D, 4, MidpointRounding.ToEven), "#2F");
990                         Assert.AreEqual (-1.5432D, Math.Round (-1.5432D, 4, MidpointRounding.AwayFromZero), "#30");
991
992                         Assert.AreEqual (63988D, Math.Round (63987.83593942D, 0, MidpointRounding.ToEven), "#31");
993                         Assert.AreEqual (63988D, Math.Round (63987.83593942D, 0, MidpointRounding.AwayFromZero), "#32");
994
995                         Assert.AreEqual (-63988D, Math.Round (-63987.83593942D, 0, MidpointRounding.ToEven), "#33");
996                         Assert.AreEqual (-63988D, Math.Round (-63987.83593942D, 0, MidpointRounding.AwayFromZero), "#34");
997
998                         Assert.AreEqual (63987.83594D, Math.Round (63987.83593942D, 5, MidpointRounding.ToEven), "#35");
999                         Assert.AreEqual (63987.83594D, Math.Round (63987.83593942D, 5, MidpointRounding.AwayFromZero), "#36");
1000
1001                         Assert.AreEqual (-63987.83594D, Math.Round (-63987.83593942D, 5, MidpointRounding.ToEven), "#37");
1002                         Assert.AreEqual (-63987.83594D, Math.Round (-63987.83593942D, 5, MidpointRounding.AwayFromZero), "#38");
1003
1004                         Assert.AreEqual (63987.83593942D, Math.Round (63987.83593942D, 8, MidpointRounding.ToEven), "#39");
1005                         Assert.AreEqual (63987.83593942D, Math.Round (63987.83593942D, 8, MidpointRounding.AwayFromZero), "#3A");
1006
1007                         Assert.AreEqual (-63987.83593942D, Math.Round (-63987.83593942D, 8, MidpointRounding.ToEven), "#3B");
1008                         Assert.AreEqual (-63987.83593942D, Math.Round (-63987.83593942D, 8, MidpointRounding.AwayFromZero), "#3C");
1009
1010                         Assert.AreEqual (1, Math.Round (0.5, 0, MidpointRounding.AwayFromZero));
1011                 }
1012                 
1013                 [Test]
1014                 public void TestDecimalSign ()
1015                 {
1016                         decimal a = -5M;
1017                         decimal b = 5M;
1018
1019                         Assert.IsTrue (Math.Sign (a) == -1, "#1");
1020                         Assert.IsTrue (Math.Sign (b) == 1, "#2");
1021                         Assert.IsTrue (Math.Sign (0M) == 0, "#3");
1022                 }
1023
1024                 [Test]
1025                 public void TestDoubleSign ()
1026                 {
1027                         double a = -5D;
1028                         double b = 5D;
1029
1030                         Assert.IsTrue (Math.Sign (a) == -1, "#1");
1031                         Assert.IsTrue (Math.Sign (b) == 1, "#2");
1032                         Assert.IsTrue (Math.Sign (0D) == 0, "#3");
1033                 }
1034
1035                 [Test]
1036                 public void TestFloatSign ()
1037                 {
1038                         float a = -5F;
1039                         float b = 5F;
1040
1041                         Assert.IsTrue (Math.Sign (a) == -1, "#1");
1042                         Assert.IsTrue (Math.Sign (b) == 1, "#2");
1043                         Assert.IsTrue (Math.Sign (0F) == 0, "#3");
1044                 }
1045
1046                 [Test]
1047                 public void TestIntSign ()
1048                 {
1049                         int a = -5;
1050                         int b = 5;
1051
1052                         Assert.IsTrue (Math.Sign (a) == -1, "#1");
1053                         Assert.IsTrue (Math.Sign (b) == 1, "#2");
1054                         Assert.IsTrue (Math.Sign (0) == 0, "#3");
1055                 }
1056
1057                 [Test]
1058                 public void TestLongSign ()
1059                 {
1060                         long a = -5L;
1061                         long b = 5L;
1062
1063                         Assert.IsTrue (Math.Sign (a) == -1, "#1");
1064                         Assert.IsTrue (Math.Sign (b) == 1, "#2");
1065                         Assert.IsTrue (Math.Sign (0L) == 0, "#3");
1066                 }
1067
1068                 [Test]
1069                 public void TestSbyteSign ()
1070                 {
1071                         sbyte a = -5;
1072                         sbyte b = 5;
1073
1074                         Assert.IsTrue (Math.Sign (a) == -1, "#1");
1075                         Assert.IsTrue (Math.Sign (b) == 1, "#2");
1076                         Assert.IsTrue (Math.Sign (0) == 0, "#3");
1077                 }
1078
1079                 [Test]
1080                 public void TestShortSign ()
1081                 {
1082                         short a = -5;
1083                         short b = 5;
1084
1085                         Assert.IsTrue (Math.Sign (a) == -1, "#1");
1086                         Assert.IsTrue (Math.Sign (b) == 1, "#2");
1087                         Assert.IsTrue (Math.Sign (0) == 0, "#3");
1088                 }
1089         }
1090 }