[jit] test builtin types (#5208)
[mono.git] / mono / mini / builtin-types.cs
1 // #define ARCH_32
2 #define NINT_JIT_OPTIMIZED
3
4 using System;
5 using System.Diagnostics;
6 using System.Globalization;
7 using System.Runtime.CompilerServices;
8 using System.Runtime.InteropServices;
9
10
11 public class BuiltinTests {
12         static int test_0_nint_ctor ()
13         {
14                 var x = new nint (10);
15                 var y = new nint (x);
16                 var z = new nint (new nint (20));
17                 if ((int)x != 10)
18                         return 1;
19                 if ((int)y != 10)
20                         return 2;
21                 if ((int)z != 20)
22                         return 3;
23                 return 0;
24         }
25
26         static int test_0_nint_casts ()
27         {
28                 var x = (nint)10;
29                 var y = (nint)20L;
30
31                 if ((int)x != 10)
32                         return 1;
33                 if ((long)x != 10L)
34                         return 2;
35                 if ((int)y != 20)
36                         return 3;
37                 if ((long)y != 20L)
38                         return 4;
39                 return 0;
40         }
41
42         static int test_0_nint_plus ()
43         {
44                 var x = (nint)10;
45                 var z = +x;
46                 if ((int)z != 10)
47                         return 1;
48                 return 0;
49         }
50
51         static int test_0_nint_neg ()
52         {
53                 var x = (nint)10;
54                 var z = -x;
55                 if ((int)z != -10)
56                         return 1;
57                 return 0;
58         }
59
60         static int test_0_nint_comp ()
61         {
62                 var x = (nint)10;
63                 var z = ~x;
64                 if ((int)z != ~10)
65                         return 1;
66                 return 0;
67         }
68
69 #if FALSE
70         static int test_0_nint_inc ()
71         {
72                 var x = (nint)10;
73                 ++x;
74                 if ((int)x != 11)
75                         return 1;
76                 return 0;
77         }
78
79         static int test_0_nint_dec ()
80         {
81                 var x = (nint)10;
82                 --x;
83                 if ((int)x != 9)
84                         return 1;
85                 return 0;
86         }
87 #endif
88
89         static int test_0_nint_add ()
90         {
91                 var x = (nint)10;
92                 var y = (nint)20;
93                 var z = x + y;
94                 if ((int)z != 30)
95                         return 1;
96                 return 0;
97         }
98
99         static int test_0_nint_sub ()
100         {
101                 var x = (nint)10;
102                 var y = (nint)20;
103                 var z = x - y;
104                 if ((int)z != -10)
105                         return 1;
106                 return 0;
107         }
108
109         static int test_0_nint_mul ()
110         {
111                 var x = (nint)10;
112                 var y = (nint)20;
113                 var z = x * y;
114                 if ((int)z != 200)
115                         return 1;
116                 return 0;
117         }
118
119         static int test_0_nint_div ()
120         {
121                 var x = (nint)30;
122                 var y = (nint)3;
123                 var z = x / y;
124                 if ((int)z != 10)
125                         return 1;
126                 return 0;
127         }
128
129         static int test_0_nint_rem ()
130         {
131                 var x = (nint)22;
132                 var y = (nint)10;
133                 var z = x % y;
134                 if ((int)z != 2)
135                         return 1;
136                 return 0;
137         }
138
139         static int test_0_nint_and ()
140         {
141                 var x = (nint)0x30;
142                 var y = (nint)0x11;
143                 var z = x & y;
144                 if ((int)z != 0x10)
145                         return 1;
146                 return 0;
147         }
148
149         static int test_0_nint_or ()
150         {
151                 var x = (nint)0x0F;
152                 var y = (nint)0xF0;
153                 var z = x | y;
154                 if ((int)z != 0xFF)
155                         return 1;
156                 return 0;
157         }
158
159         static int test_0_nint_xor ()
160         {
161                 var x = (nint)0xFF;
162                 var y = (nint)0xF0;
163                 var z = x ^ y;
164                 if ((int)z != 0x0F)
165                         return 1;
166                 return 0;
167         }
168
169         static int test_0_nint_shl ()
170         {
171                 var x = (nint)10;
172                 var z = x << 2;
173                 if ((int)z != 40)
174                         return 1;
175                 return 0;
176         }
177
178         static int test_0_nint_shr ()
179         {
180                 var x = (nint)10;
181                 var z = x >> 2;
182                 if ((int)z != 2)
183                         return 1;
184                 return 0;
185         }
186
187         static int test_0_nint_cmp_same_val ()
188         {
189                 var x = (nint)10;
190                 var y = (nint)10;
191                 if (!(x == y))
192                         return 1;
193                 if (x != y)
194                         return 2;
195                 if (x < y)
196                         return 3;
197                 if (x > y)
198                         return 4;
199                 if (!(x <= y))
200                         return 5;
201                 if (!(x >= y))
202                         return 6;
203                 return 0;
204         }
205
206         static int test_0_nint_cmp_small_val ()
207         {
208                 var x = (nint)5;
209                 var y = (nint)10;
210                 if (x == y)
211                         return 1;
212                 if (!(x != y))
213                         return 2;
214                 if (!(x < y))
215                         return 3;
216                 if (x > y)
217                         return 4;
218                 if (!(x <= y))
219                         return 5;
220                 if (x >= y)
221                         return 6;
222                 return 0;
223         }
224
225         static int test_0_nint_cmp_large_val ()
226         {
227                 var x = (nint)20;
228                 var y = (nint)10;
229                 if (x == y)
230                         return 1;
231                 if (!(x != y))
232                         return 2;
233                 if (x < y)
234                         return 3;
235                 if (!(x > y))
236                         return 4;
237                 if (x <= y)
238                         return 1;
239                 if (!(x >= y))
240                         return 1;
241                 return 0;
242         }
243
244         // static int test_0_nint_call_boxed_equals ()
245         // {
246         //      object x = new nint (10);
247         //      object y = new nint (10);
248         //      if (!x.Equals (y))
249         //              return 1;
250         //      return 0;
251         // }
252
253         static int test_0_nint_call_boxed_funs ()
254         {
255                 object x = new nint (10);
256                 object y = new nint (10);
257                 if (x.GetHashCode () == 0)
258                         return 2;
259                 if (x.ToString () != "10")
260                         return 3;
261                 return 0;
262         }
263
264         public int test_0_nint_unboxed_member_calls ()
265         {
266                 var x = (nint)10;
267 #if FALSE
268                 if (!x.Equals (x))
269                         return 1;
270 #endif
271                 if (x != nint.Parse ("10"))
272                         return 2;
273                 return 0;
274         }
275
276         static int test_0_nuint_ctor ()
277         {
278                 var x = new nuint (10u);
279                 var y = new nuint (x);
280                 var z = new nuint (new nuint (20u));
281                 if ((uint)x != 10)
282                         return 1;
283                 if ((uint)y != 10)
284                         return 2;
285                 if ((uint)z != 20)
286                         return 3;
287                 return 0;
288         }
289
290         static int test_0_nuint_casts ()
291         {
292                 var x = (nuint)10;
293                 var y = (nuint)20L;
294
295                 if ((uint)x != 10)
296                         return 1;
297                 if ((ulong)x != 10L)
298                         return 2;
299                 if ((uint)y != 20)
300                         return 3;
301                 if ((ulong)y != 20L)
302                         return 4;
303                 return 0;
304         }
305
306         static int test_0_nuint_plus ()
307         {
308                 var x = (nuint)10;
309                 var z = +x;
310                 if ((uint)z != 10)
311                         return 1;
312                 return 0;
313         }
314
315         // static int test_0_nuint_neg ()
316         // {
317         //      var x = (nuint)10;
318         //      var z = -x;
319         //      if ((uint)z != -10)
320         //              return 1;
321         //      return 0;
322         // }
323
324         static int test_0_nuint_comp ()
325         {
326                 var x = (nuint)10;
327                 var z = ~x;
328                 if ((uint)z != ~10u)
329                         return 1;
330                 return 0;
331         }
332
333 #if FALSE
334         static int test_0_nuint_inc ()
335         {
336                 var x = (nuint)10;
337                 ++x;
338                 if ((uint)x != 11)
339                         return 1;
340                 return 0;
341         }
342
343         static int test_0_nuint_dec ()
344         {
345                 var x = (nuint)10;
346                 --x;
347                 if ((uint)x != 9)
348                         return 1;
349                 return 0;
350         }
351 #endif
352
353         static int test_0_nuint_add ()
354         {
355                 var x = (nuint)10;
356                 var y = (nuint)20;
357                 var z = x + y;
358                 if ((uint)z != 30)
359                         return 1;
360                 return 0;
361         }
362
363         static int test_0_nuint_sub ()
364         {
365                 var x = (nuint)20;
366                 var y = (nuint)5;
367                 var z = x - y;
368                 if ((uint)z != 15)
369                         return 1;
370                 return 0;
371         }
372
373         static int test_0_nuint_mul ()
374         {
375                 var x = (nuint)10;
376                 var y = (nuint)20;
377                 var z = x * y;
378                 if ((uint)z != 200)
379                         return 1;
380                 return 0;
381         }
382
383         static int test_0_nuint_div ()
384         {
385                 var x = (nuint)30;
386                 var y = (nuint)3;
387                 var z = x / y;
388                 if ((uint)z != 10)
389                         return 1;
390                 return 0;
391         }
392
393         static int test_0_nuint_rem ()
394         {
395                 var x = (nuint)22;
396                 var y = (nuint)10;
397                 var z = x % y;
398                 if ((uint)z != 2)
399                         return 1;
400                 return 0;
401         }
402
403         static int test_0_nuint_and ()
404         {
405                 var x = (nuint)0x30;
406                 var y = (nuint)0x11;
407                 var z = x & y;
408                 if ((uint)z != 0x10)
409                         return 1;
410                 return 0;
411         }
412
413         static int test_0_nuint_or ()
414         {
415                 var x = (nuint)0x0F;
416                 var y = (nuint)0xF0;
417                 var z = x | y;
418                 if ((uint)z != 0xFF)
419                         return 1;
420                 return 0;
421         }
422
423         static int test_0_nuint_xor ()
424         {
425                 var x = (nuint)0xFF;
426                 var y = (nuint)0xF0;
427                 var z = x ^ y;
428                 if ((uint)z != 0x0F)
429                         return 1;
430                 return 0;
431         }
432
433         static int test_0_nuint_shl ()
434         {
435                 var x = (nuint)10;
436                 var z = x << 2;
437                 if ((uint)z != 40)
438                         return 1;
439                 return 0;
440         }
441
442         static int test_0_nuint_shr ()
443         {
444                 var x = (nuint)10;
445                 var z = x >> 2;
446                 if ((uint)z != 2)
447                         return 1;
448                 return 0;
449         }
450
451         static int test_0_nuint_cmp_same_val ()
452         {
453                 var x = (nuint)10;
454                 var y = (nuint)10;
455                 if (!(x == y))
456                         return 1;
457                 if (x != y)
458                         return 2;
459                 if (x < y)
460                         return 3;
461                 if (x > y)
462                         return 4;
463                 if (!(x <= y))
464                         return 5;
465                 if (!(x >= y))
466                         return 6;
467                 return 0;
468         }
469
470         static int test_0_nuint_cmp_small_val ()
471         {
472                 var x = (nuint)5;
473                 var y = (nuint)10;
474                 if (x == y)
475                         return 1;
476                 if (!(x != y))
477                         return 2;
478                 if (!(x < y))
479                         return 3;
480                 if (x > y)
481                         return 4;
482                 if (!(x <= y))
483                         return 5;
484                 if (x >= y)
485                         return 6;
486                 return 0;
487         }
488
489         static int test_0_nuint_cmp_large_val ()
490         {
491                 var x = (nuint)20;
492                 var y = (nuint)10;
493                 if (x == y)
494                         return 1;
495                 if (!(x != y))
496                         return 2;
497                 if (x < y)
498                         return 3;
499                 if (!(x > y))
500                         return 4;
501                 if (x <= y)
502                         return 1;
503                 if (!(x >= y))
504                         return 1;
505                 return 0;
506         }
507
508         // static int test_0_nuint_call_boxed_equals ()
509         // {
510         //      object x = new nuint (10);
511         //      object y = new nuint (10);
512         //      if (!x.Equals (y))
513         //              return 1;
514         //      return 0;
515         // }
516
517         static int test_0_nuint_call_boxed_funs ()
518         {
519                 object x = new nuint (10u);
520                 object y = new nuint (10u);
521                 if (x.GetHashCode () == 0)
522                         return 2;
523                 if (x.ToString () != "10")
524                         return 3;
525                 return 0;
526         }
527
528         public int test_0_nuint_unboxed_member_calls ()
529         {
530                 var x = (nuint)10;
531 #if FALSE
532                 if (!x.Equals (x))
533                         return 1;
534 #endif
535                 if (x != nuint.Parse ("10"))
536                         return 2;
537                 return 0;
538         }
539
540         static int test_0_nfloat_ctor ()
541         {
542                 var x = new nfloat (10.0f);
543                 var y = new nfloat (x);
544                 var z = new nfloat (new nfloat (20f));
545                 if ((float)x != 10f)
546                         return 1;
547                 if ((float)y != 10f)
548                         return 2;
549                 if ((float)z != 20f)
550                         return 3;
551                 return 0;
552         }
553
554         static int test_0_nfloat_casts ()
555         {
556                 var x = (nfloat)10f;
557
558                 if ((float)x != 10f)
559                         return 1;
560                 if ((double)x != 10)
561                         return 2;
562 #if FALSE
563                 var y = (nfloat)20;
564                 if ((float)y != 20f)
565                         return 3;
566                 if ((double)y != 20)
567                         return 4;
568 #endif
569                 return 0;
570         }
571
572         static int test_0_nfloat_plus ()
573         {
574                 var x = (nfloat)10f;
575                 var z = +x;
576                 if ((float)z != 10f)
577                         return 1;
578                 return 0;
579         }
580
581         static int test_0_nfloat_neg ()
582         {
583                 var x = (nfloat)10f;
584                 var z = -x;
585                 if ((float)z != -10f)
586                         return 1;
587                 return 0;
588         }
589
590 #if FALSE
591         static int test_0_nfloat_inc ()
592         {
593                 var x = (nfloat)10f;
594                 ++x;
595                 if ((float)x != 11f) {
596                         Console.WriteLine ((float)x);
597                         return 1;
598                 }
599                 return 0;
600         }
601
602         static int test_0_nfloat_dec ()
603         {
604                 var x = (nfloat)10f;
605                 --x;
606                 if ((float)x != 9f) {
607                         Console.WriteLine ((float)x);
608                         return 1;
609                 }
610                 return 0;
611         }
612 #endif
613
614         static int test_0_nfloat_add ()
615         {
616                 var x = (nfloat)10f;
617                 var y = (nfloat)20f;
618                 var z = x + y;
619                 if ((float)z != 30f)
620                         return 1;
621                 return 0;
622         }
623
624         static int test_0_nfloat_sub ()
625         {
626                 var x = (nfloat)10f;
627                 var y = (nfloat)20f;
628                 var z = x - y;
629                 if ((float)z != -10f)
630                         return 1;
631                 return 0;
632         }
633
634         static int test_0_nfloat_mul ()
635         {
636                 var x = (nfloat)10f;
637                 var y = (nfloat)20f;
638                 var z = x * y;
639                 if ((float)z != 200f)
640                         return 1;
641                 return 0;
642         }
643
644         static int test_0_nfloat_div ()
645         {
646                 var x = (nfloat)30f;
647                 var y = (nfloat)3f;
648                 var z = x / y;
649                 if ((float)z != 10f)
650                         return 1;
651                 return 0;
652         }
653
654         static int test_0_nfloat_rem ()
655         {
656                 var x = (nfloat)22f;
657                 var y = (nfloat)10f;
658                 var z = x % y;
659                 if ((float)z != 2f)
660                         return 1;
661                 return 0;
662         }
663
664         static int test_0_nfloat_cmp_same_val ()
665         {
666                 var x = (nfloat)10f;
667                 var y = (nfloat)10f;
668                 if (!(x == y))
669                         return 1;
670                 if (x != y)
671                         return 2;
672                 if (x < y)
673                         return 3;
674                 if (x > y)
675                         return 4;
676                 if (!(x <= y))
677                         return 5;
678                 if (!(x >= y))
679                         return 6;
680                 return 0;
681         }
682
683         static int test_0_nfloat_cmp_small_val ()
684         {
685                 var x = (nfloat)5f;
686                 var y = (nfloat)10f;
687                 if (x == y)
688                         return 1;
689                 if (!(x != y))
690                         return 2;
691                 if (!(x < y))
692                         return 3;
693                 if (x > y)
694                         return 4;
695                 if (!(x <= y))
696                         return 5;
697                 if (x >= y)
698                         return 6;
699                 return 0;
700         }
701
702         static int test_0_nfloat_cmp_large_val ()
703         {
704                 var x = (nfloat)20f;
705                 var y = (nfloat)10f;
706                 if (x == y)
707                         return 1;
708                 if (!(x != y))
709                         return 2;
710                 if (x < y)
711                         return 3;
712                 if (!(x > y))
713                         return 4;
714                 if (x <= y)
715                         return 1;
716                 if (!(x >= y))
717                         return 1;
718                 return 0;
719         }
720
721         /* fails on arm64 */
722 #if FALSE
723         static int test_0_nfloat_cmp_left_nan ()
724         {
725                 var x = (nfloat)float.NaN;
726                 var y = (nfloat)10f;
727                 if (x == y)
728                         return 1;
729                 if (!(x != y))
730                         return 2;
731                 if (x < y)
732                         return 3;
733                 if (x > y)
734                         return 4;
735                 if (x <= y)
736                         return 1;
737                 if (x >= y)
738                         return 1;
739                 return 0;
740         }
741
742
743         static int test_0_nfloat_cmp_right_nan ()
744         {
745                 var x = (nfloat)10f;
746                 var y = (nfloat)float.NaN;
747                 if (x == y)
748                         return 1;
749                 if (!(x != y))
750                         return 2;
751                 if (x < y)
752                         return 3;
753                 if (x > y)
754                         return 4;
755                 if (x <= y)
756                         return 1;
757                 if (x >= y)
758                         return 1;
759                 return 0;
760         }
761 #endif
762
763         // static int test_0_nfloat_call_boxed_equals ()
764         // {
765         //      object x = new nfloat (10f);
766         //      object y = new nfloat (10f);
767         //      if (!x.Equals (y))
768         //              return 1;
769         //      return 0;
770         // }
771
772         static int test_0_nfloat_call_boxed_funs ()
773         {
774                 object x = new nfloat (10f);
775                 object y = new nfloat (10f);
776                 if (x.GetHashCode () == 0)
777                         return 2;
778                 if (x.ToString () != "10")
779                         return 3;
780                 return 0;
781         }
782
783         public int test_0_nfloat_unboxed_member_calls ()
784         {
785                 var x = (nfloat)10f;
786 #if FALSE
787                 if (!x.Equals (x))
788                         return 1;
789 #endif
790                 if (x != nfloat.Parse ("10"))
791                         return 2;
792                 return 0;
793         }
794
795         public static int Main (String[] args) {
796                 return TestDriver.RunTests (typeof (BuiltinTests), args);
797         }
798 }
799
800
801 // !!! WARNING - GENERATED CODE - DO NOT EDIT !!!
802 //
803 // Generated by NativeTypes.tt, a T4 template.
804 //
805 // NativeTypes.cs: basic types with 32 or 64 bit sizes:
806 //
807 //   - nint
808 //   - nuint
809 //   - nfloat
810 //
811 // Authors:
812 //   Aaron Bockover <abock@xamarin.com>
813 //
814 // Copyright 2013 Xamarin, Inc. All rights reserved.
815 //
816
817 namespace System
818 {
819         [Serializable]
820         [DebuggerDisplay ("{v,nq}")]
821         public unsafe struct nint : IFormattable, IConvertible, IComparable, IComparable<nint>, IEquatable <nint>
822         {
823                 internal nint (nint v) { this.v = v.v; }
824                 public nint (Int32 v) { this.v = v; }
825
826 #if ARCH_32
827                 public static readonly int Size = 4;
828
829                 public static readonly nint MaxValue = Int32.MaxValue;
830                 public static readonly nint MinValue = Int32.MinValue;
831
832                 [DebuggerBrowsable (DebuggerBrowsableState.Never)]
833                 internal Int32 v;
834
835                 public nint (Int64 v) { this.v = (Int32)v; }
836 #else
837                 public static readonly int Size = 8;
838
839                 public static readonly nint MaxValue = (nint) Int64.MaxValue; // 64-bit only codepath
840                 public static readonly nint MinValue = (nint) Int64.MinValue; // 64-bit only codepath
841
842                 [DebuggerBrowsable (DebuggerBrowsableState.Never)]
843                 internal Int64 v;
844
845                 public nint (Int64 v) { this.v = v; }
846 #endif
847
848                 public static explicit operator nint (nuint v)
849                 {
850 #if NINT_JIT_OPTIMIZED
851                         throw new NotImplementedException ();
852 #elif ARCH_32
853                         return new nint ((int)v.v);
854 #else
855                         return new nint ((long)v.v);
856 #endif
857                 }
858
859                 public static explicit operator nuint (nint v)
860                 {
861 #if NINT_JIT_OPTIMIZED
862                         throw new NotImplementedException ();
863 #elif ARCH_32
864                         return new nuint ((uint)v.v);
865 #else
866                         return new nuint ((ulong)v.v);
867 #endif
868                 }
869
870                 public static explicit operator nint (nfloat v)
871                 {
872 #if NINT_JIT_OPTIMIZED
873                         throw new NotImplementedException ();
874 #elif ARCH_32
875                         return new nint ((int)v.v);
876 #else
877                         return new nint ((long)v.v);
878 #endif
879                 }
880
881                 public static implicit operator nfloat (nint v)
882                 {
883 #if NINT_JIT_OPTIMIZED
884                         throw new NotImplementedException ();
885 #elif ARCH_32
886                         return new nfloat ((float)v.v);
887 #else
888                         return new nfloat ((double)v.v);
889 #endif
890                 }
891
892                 public static explicit operator nint (IntPtr v)
893                 {
894 #if NINT_JIT_OPTIMIZED
895                         throw new NotImplementedException ();
896 #elif ARCH_32
897                         return new nint (*((int *)&v));
898 #else
899                         return new nint (*((long *)&v));
900 #endif
901                 }
902
903                 public static explicit operator IntPtr (nint v)
904                 {
905 #if NINT_JIT_OPTIMIZED
906                         throw new NotImplementedException ();
907 #elif ARCH_32
908                         return *((IntPtr *)&v.v);
909 #else
910                         return *((IntPtr *)&v.v);
911 #endif
912                 }
913
914                 public static implicit operator nint (sbyte v)
915                 {
916 #if NINT_JIT_OPTIMIZED
917                         throw new NotImplementedException ();
918 #elif ARCH_32
919                         return new nint ((int)v);
920 #else
921                         return new nint ((long)v);
922 #endif
923                 }
924
925                 public static explicit operator sbyte (nint v)
926                 {
927 #if NINT_JIT_OPTIMIZED
928                         throw new NotImplementedException ();
929 #elif ARCH_32
930                         return (sbyte)v.v;
931 #else
932                         return (sbyte)v.v;
933 #endif
934                 }
935
936                 public static implicit operator nint (byte v)
937                 {
938 #if NINT_JIT_OPTIMIZED
939                         throw new NotImplementedException ();
940 #elif ARCH_32
941                         return new nint ((int)v);
942 #else
943                         return new nint ((long)v);
944 #endif
945                 }
946
947                 public static explicit operator byte (nint v)
948                 {
949 #if NINT_JIT_OPTIMIZED
950                         throw new NotImplementedException ();
951 #elif ARCH_32
952                         return (byte)v.v;
953 #else
954                         return (byte)v.v;
955 #endif
956                 }
957
958                 public static implicit operator nint (char v)
959                 {
960 #if NINT_JIT_OPTIMIZED
961                         throw new NotImplementedException ();
962 #elif ARCH_32
963                         return new nint ((int)v);
964 #else
965                         return new nint ((long)v);
966 #endif
967                 }
968
969                 public static explicit operator char (nint v)
970                 {
971 #if NINT_JIT_OPTIMIZED
972                         throw new NotImplementedException ();
973 #elif ARCH_32
974                         return (char)v.v;
975 #else
976                         return (char)v.v;
977 #endif
978                 }
979
980                 public static implicit operator nint (short v)
981                 {
982 #if NINT_JIT_OPTIMIZED
983                         throw new NotImplementedException ();
984 #elif ARCH_32
985                         return new nint ((int)v);
986 #else
987                         return new nint ((long)v);
988 #endif
989                 }
990
991                 public static explicit operator short (nint v)
992                 {
993 #if NINT_JIT_OPTIMIZED
994                         throw new NotImplementedException ();
995 #elif ARCH_32
996                         return (short)v.v;
997 #else
998                         return (short)v.v;
999 #endif
1000                 }
1001
1002                 public static explicit operator nint (ushort v)
1003                 {
1004 #if NINT_JIT_OPTIMIZED
1005                         throw new NotImplementedException ();
1006 #elif ARCH_32
1007                         return new nint ((int)v);
1008 #else
1009                         return new nint ((long)v);
1010 #endif
1011                 }
1012
1013                 public static explicit operator ushort (nint v)
1014                 {
1015 #if NINT_JIT_OPTIMIZED
1016                         throw new NotImplementedException ();
1017 #elif ARCH_32
1018                         return (ushort)v.v;
1019 #else
1020                         return (ushort)v.v;
1021 #endif
1022                 }
1023
1024                 public static implicit operator nint (int v)
1025                 {
1026 #if NINT_JIT_OPTIMIZED
1027                         throw new NotImplementedException ();
1028 #elif ARCH_32
1029                         return new nint ((int)v);
1030 #else
1031                         return new nint ((long)v);
1032 #endif
1033                 }
1034
1035                 public static explicit operator int (nint v)
1036                 {
1037 #if NINT_JIT_OPTIMIZED
1038                         throw new NotImplementedException ();
1039 #elif ARCH_32
1040                         return (int)v.v;
1041 #else
1042                         return (int)v.v;
1043 #endif
1044                 }
1045
1046                 public static explicit operator nint (uint v)
1047                 {
1048 #if NINT_JIT_OPTIMIZED
1049                         throw new NotImplementedException ();
1050 #elif ARCH_32
1051                         return new nint ((int)v);
1052 #else
1053                         return new nint ((long)v);
1054 #endif
1055                 }
1056
1057                 public static explicit operator uint (nint v)
1058                 {
1059 #if NINT_JIT_OPTIMIZED
1060                         throw new NotImplementedException ();
1061 #elif ARCH_32
1062                         return (uint)v.v;
1063 #else
1064                         return (uint)v.v;
1065 #endif
1066                 }
1067
1068                 public static explicit operator nint (long v)
1069                 {
1070 #if NINT_JIT_OPTIMIZED
1071                         throw new NotImplementedException ();
1072 #elif ARCH_32
1073                         return new nint ((int)v);
1074 #else
1075                         return new nint ((long)v);
1076 #endif
1077                 }
1078
1079                 public static implicit operator long (nint v)
1080                 {
1081 #if NINT_JIT_OPTIMIZED
1082                         throw new NotImplementedException ();
1083 #elif ARCH_32
1084                         return (long)v.v;
1085 #else
1086                         return (long)v.v;
1087 #endif
1088                 }
1089
1090                 public static explicit operator nint (ulong v)
1091                 {
1092 #if NINT_JIT_OPTIMIZED
1093                         throw new NotImplementedException ();
1094 #elif ARCH_32
1095                         return new nint ((int)v);
1096 #else
1097                         return new nint ((long)v);
1098 #endif
1099                 }
1100
1101                 public static explicit operator ulong (nint v)
1102                 {
1103 #if NINT_JIT_OPTIMIZED
1104                         throw new NotImplementedException ();
1105 #elif ARCH_32
1106                         return (ulong)v.v;
1107 #else
1108                         return (ulong)v.v;
1109 #endif
1110                 }
1111
1112                 public static explicit operator nint (float v)
1113                 {
1114 #if NINT_JIT_OPTIMIZED
1115                         throw new NotImplementedException ();
1116 #elif ARCH_32
1117                         return new nint ((int)v);
1118 #else
1119                         return new nint ((long)v);
1120 #endif
1121                 }
1122
1123                 public static implicit operator float (nint v)
1124                 {
1125 #if NINT_JIT_OPTIMIZED
1126                         throw new NotImplementedException ();
1127 #elif ARCH_32
1128                         return (float)v.v;
1129 #else
1130                         return (float)v.v;
1131 #endif
1132                 }
1133
1134                 public static explicit operator nint (double v)
1135                 {
1136 #if NINT_JIT_OPTIMIZED
1137                         throw new NotImplementedException ();
1138 #elif ARCH_32
1139                         return new nint ((int)v);
1140 #else
1141                         return new nint ((long)v);
1142 #endif
1143                 }
1144
1145                 public static implicit operator double (nint v)
1146                 {
1147 #if NINT_JIT_OPTIMIZED
1148                         throw new NotImplementedException ();
1149 #elif ARCH_32
1150                         return (double)v.v;
1151 #else
1152                         return (double)v.v;
1153 #endif
1154                 }
1155
1156                 public static explicit operator nint (decimal v)
1157                 {
1158 #if NINT_JIT_OPTIMIZED
1159                         throw new NotImplementedException ();
1160 #elif ARCH_32
1161                         return new nint ((int)v);
1162 #else
1163                         return new nint ((long)v);
1164 #endif
1165                 }
1166
1167                 public static implicit operator decimal (nint v)
1168                 {
1169 #if NINT_JIT_OPTIMIZED
1170                         throw new NotImplementedException ();
1171 #elif ARCH_32
1172                         return (decimal)v.v;
1173 #else
1174                         return (decimal)v.v;
1175 #endif
1176                 }
1177
1178 #if NINT_JIT_OPTIMIZED
1179                 public static nint operator + (nint v) { throw new NotImplementedException (); }
1180                 public static nint operator - (nint v) { throw new NotImplementedException (); }
1181                 public static nint operator ~ (nint v) { throw new NotImplementedException (); }
1182 #else
1183                 public static nint operator + (nint v) { return new nint (+v.v); }
1184                 public static nint operator - (nint v) { return new nint (-v.v); }
1185                 public static nint operator ~ (nint v) { return new nint (~v.v); }
1186 #endif
1187
1188 #if NINT_JIT_OPTIMIZED
1189                 public static nint operator ++ (nint v) { throw new NotImplementedException (); }
1190                 public static nint operator -- (nint v) { throw new NotImplementedException (); }
1191 #else
1192                 public static nint operator ++ (nint v) { return new nint (v.v + 1); }
1193                 public static nint operator -- (nint v) { return new nint (v.v - 1); }
1194 #endif
1195
1196 #if NINT_JIT_OPTIMIZED
1197                 public static nint operator + (nint l, nint r) { throw new NotImplementedException (); }
1198                 public static nint operator - (nint l, nint r) { throw new NotImplementedException (); }
1199                 public static nint operator * (nint l, nint r) { throw new NotImplementedException (); }
1200                 public static nint operator / (nint l, nint r) { throw new NotImplementedException (); }
1201                 public static nint operator % (nint l, nint r) { throw new NotImplementedException (); }
1202                 public static nint operator & (nint l, nint r) { throw new NotImplementedException (); }
1203                 public static nint operator | (nint l, nint r) { throw new NotImplementedException (); }
1204                 public static nint operator ^ (nint l, nint r) { throw new NotImplementedException (); }
1205
1206                 public static nint operator << (nint l, int r) { throw new NotImplementedException (); }
1207                 public static nint operator >> (nint l, int r) { throw new NotImplementedException (); }
1208 #else
1209                 public static nint operator + (nint l, nint r) { return new nint (l.v + r.v); }
1210                 public static nint operator - (nint l, nint r) { return new nint (l.v - r.v); }
1211                 public static nint operator * (nint l, nint r) { return new nint (l.v * r.v); }
1212                 public static nint operator / (nint l, nint r) { return new nint (l.v / r.v); }
1213                 public static nint operator % (nint l, nint r) { return new nint (l.v % r.v); }
1214                 public static nint operator & (nint l, nint r) { return new nint (l.v & r.v); }
1215                 public static nint operator | (nint l, nint r) { return new nint (l.v | r.v); }
1216                 public static nint operator ^ (nint l, nint r) { return new nint (l.v ^ r.v); }
1217
1218                 public static nint operator << (nint l, int r) { return new nint (l.v << r); }
1219                 public static nint operator >> (nint l, int r) { return new nint (l.v >> r); }
1220 #endif
1221
1222 #if NINT_JIT_OPTIMIZED
1223                 public static bool operator == (nint l, nint r) { throw new NotImplementedException (); }
1224                 public static bool operator != (nint l, nint r) { throw new NotImplementedException (); }
1225                 public static bool operator <  (nint l, nint r) { throw new NotImplementedException (); }
1226                 public static bool operator >  (nint l, nint r) { throw new NotImplementedException (); }
1227                 public static bool operator <= (nint l, nint r) { throw new NotImplementedException (); }
1228                 public static bool operator >= (nint l, nint r) { throw new NotImplementedException (); }
1229 #else
1230                 public static bool operator == (nint l, nint r) { return l.v == r.v; }
1231                 public static bool operator != (nint l, nint r) { return l.v != r.v; }
1232                 public static bool operator <  (nint l, nint r) { return l.v < r.v; }
1233                 public static bool operator >  (nint l, nint r) { return l.v > r.v; }
1234                 public static bool operator <= (nint l, nint r) { return l.v <= r.v; }
1235                 public static bool operator >= (nint l, nint r) { return l.v >= r.v; }
1236 #endif
1237
1238                 public int CompareTo (nint value) { return v.CompareTo (value.v); }
1239                 public int CompareTo (object value)
1240                 {
1241                         if (value is nint)
1242                                 return v.CompareTo (((nint) value).v);
1243                         return v.CompareTo (value);
1244                 }
1245                 public bool Equals (nint obj) { return v.Equals (obj.v); }
1246                 public override bool Equals (object obj)
1247                 {
1248                         if (obj is nint)
1249                                 return v.Equals (((nint) obj).v);
1250                         return v.Equals (obj);
1251                 }
1252                 public override int GetHashCode () { return v.GetHashCode (); }
1253
1254 #if ARCH_32
1255                 public static nint Parse (string s, IFormatProvider provider) { return (nint)Int32.Parse (s, provider); }
1256                 public static nint Parse (string s, NumberStyles style) { return (nint)Int32.Parse (s, style); }
1257                 public static nint Parse (string s) { return (nint)Int32.Parse (s); }
1258                 public static nint Parse (string s, NumberStyles style, IFormatProvider provider) {
1259                         return (nint)Int32.Parse (s, style, provider);
1260                 }
1261
1262                 public static bool TryParse (string s, out nint result)
1263                 {
1264                         Int32 v;
1265                         var r = Int32.TryParse (s, out v);
1266                         result = (nint)v;
1267                         return r;
1268                 }
1269
1270                 public static bool TryParse (string s, NumberStyles style, IFormatProvider provider, out nint result)
1271                 {
1272                         Int32 v;
1273                         var r = Int32.TryParse (s, style, provider, out v);
1274                         result = (nint)v;
1275                         return r;
1276                 }
1277 #else
1278                 public static nint Parse (string s, IFormatProvider provider) { return (nint)Int64.Parse (s, provider); }
1279                 public static nint Parse (string s, NumberStyles style) { return (nint)Int64.Parse (s, style); }
1280                 public static nint Parse (string s) { return (nint)Int64.Parse (s); }
1281                 public static nint Parse (string s, NumberStyles style, IFormatProvider provider) {
1282                         return (nint)Int64.Parse (s, style, provider);
1283                 }
1284
1285                 public static bool TryParse (string s, out nint result)
1286                 {
1287                         Int64 v;
1288                         var r = Int64.TryParse (s, out v);
1289                         result = (nint)v;
1290                         return r;
1291                 }
1292
1293                 public static bool TryParse (string s, NumberStyles style, IFormatProvider provider, out nint result)
1294                 {
1295                         Int64 v;
1296                         var r = Int64.TryParse (s, style, provider, out v);
1297                         result = (nint)v;
1298                         return r;
1299                 }
1300 #endif
1301
1302                 public override string ToString () { return v.ToString (); }
1303                 public string ToString (IFormatProvider provider) { return v.ToString (provider); }
1304                 public string ToString (string format) { return v.ToString (format); }
1305                 public string ToString (string format, IFormatProvider provider) { return v.ToString (format, provider); }
1306
1307                 public TypeCode GetTypeCode () { return v.GetTypeCode (); }
1308
1309                 bool     IConvertible.ToBoolean  (IFormatProvider provider) { return ((IConvertible)v).ToBoolean (provider); }
1310                 byte     IConvertible.ToByte     (IFormatProvider provider) { return ((IConvertible)v).ToByte (provider); }
1311                 char     IConvertible.ToChar     (IFormatProvider provider) { return ((IConvertible)v).ToChar (provider); }
1312                 DateTime IConvertible.ToDateTime (IFormatProvider provider) { return ((IConvertible)v).ToDateTime (provider); }
1313                 decimal  IConvertible.ToDecimal  (IFormatProvider provider) { return ((IConvertible)v).ToDecimal (provider); }
1314                 double   IConvertible.ToDouble   (IFormatProvider provider) { return ((IConvertible)v).ToDouble (provider); }
1315                 short    IConvertible.ToInt16    (IFormatProvider provider) { return ((IConvertible)v).ToInt16 (provider); }
1316                 int      IConvertible.ToInt32    (IFormatProvider provider) { return ((IConvertible)v).ToInt32 (provider); }
1317                 long     IConvertible.ToInt64    (IFormatProvider provider) { return ((IConvertible)v).ToInt64 (provider); }
1318                 sbyte    IConvertible.ToSByte    (IFormatProvider provider) { return ((IConvertible)v).ToSByte (provider); }
1319                 float    IConvertible.ToSingle   (IFormatProvider provider) { return ((IConvertible)v).ToSingle (provider); }
1320                 ushort   IConvertible.ToUInt16   (IFormatProvider provider) { return ((IConvertible)v).ToUInt16 (provider); }
1321                 uint     IConvertible.ToUInt32   (IFormatProvider provider) { return ((IConvertible)v).ToUInt32 (provider); }
1322                 ulong    IConvertible.ToUInt64   (IFormatProvider provider) { return ((IConvertible)v).ToUInt64 (provider); }
1323
1324                 object IConvertible.ToType (Type targetType, IFormatProvider provider) {
1325                         return ((IConvertible)v).ToType (targetType, provider);
1326                 }
1327
1328                 public static void CopyArray (IntPtr source, nint [] destination, int startIndex, int length)
1329                 {
1330                         if (source == IntPtr.Zero)
1331                                 throw new ArgumentNullException ("source");
1332                         if (destination == null)
1333                                 throw new ArgumentNullException ("destination");
1334                         if (destination.Rank != 1)
1335                                 throw new ArgumentException ("destination", "array is multi-dimensional");
1336                         if (startIndex < 0)
1337                                 throw new ArgumentException ("startIndex", "must be >= 0");
1338                         if (length < 0)
1339                                 throw new ArgumentException ("length", "must be >= 0");
1340                         if (startIndex + length > destination.Length)
1341                                 throw new ArgumentException ("length", "startIndex + length > destination.Length");
1342
1343                         for (int i = 0; i < length; i++)
1344                                 destination [i + startIndex] = (nint)Marshal.ReadIntPtr (source, i * nint.Size);
1345                 }
1346
1347                 public static void CopyArray (nint [] source, int startIndex, IntPtr destination, int length)
1348                 {
1349                         if (source == null)
1350                                 throw new ArgumentNullException ("source");
1351                         if (destination == IntPtr.Zero)
1352                                 throw new ArgumentNullException ("destination");
1353                         if (source.Rank != 1)
1354                                 throw new ArgumentException ("source", "array is multi-dimensional");
1355                         if (startIndex < 0)
1356                                 throw new ArgumentException ("startIndex", "must be >= 0");
1357                         if (length < 0)
1358                                 throw new ArgumentException ("length", "must be >= 0");
1359                         if (startIndex + length > source.Length)
1360                                 throw new ArgumentException ("length", "startIndex + length > source.Length");
1361
1362                         for (int i = 0; i < length; i++)
1363                                 Marshal.WriteIntPtr (destination, i * nint.Size, (IntPtr)source [i + startIndex]);
1364                 }
1365         }
1366         [Serializable]
1367         [DebuggerDisplay ("{v,nq}")]
1368         public unsafe struct nuint : IFormattable, IConvertible, IComparable, IComparable<nuint>, IEquatable <nuint>
1369         {
1370                 internal nuint (nuint v) { this.v = v.v; }
1371                 public nuint (UInt32 v) { this.v = v; }
1372
1373 #if ARCH_32
1374                 public static readonly int Size = 4;
1375
1376                 public static readonly nuint MaxValue = UInt32.MaxValue;
1377                 public static readonly nuint MinValue = UInt32.MinValue;
1378
1379                 [DebuggerBrowsable (DebuggerBrowsableState.Never)]
1380                 internal UInt32 v;
1381
1382                 public nuint (UInt64 v) { this.v = (UInt32)v; }
1383 #else
1384                 public static readonly int Size = 8;
1385
1386                 public static readonly nuint MaxValue = (nuint) UInt64.MaxValue; // 64-bit only codepath
1387                 public static readonly nuint MinValue = (nuint) UInt64.MinValue; // 64-bit only codepath
1388
1389                 [DebuggerBrowsable (DebuggerBrowsableState.Never)]
1390                 internal UInt64 v;
1391
1392                 public nuint (UInt64 v) { this.v = v; }
1393 #endif
1394
1395                 public static explicit operator nuint (nfloat v)
1396                 {
1397 #if NINT_JIT_OPTIMIZED
1398                         throw new NotImplementedException ();
1399 #elif ARCH_32
1400                         return new nuint ((uint)v.v);
1401 #else
1402                         return new nuint ((ulong)v.v);
1403 #endif
1404                 }
1405
1406                 public static implicit operator nfloat (nuint v)
1407                 {
1408 #if NINT_JIT_OPTIMIZED
1409                         throw new NotImplementedException ();
1410 #elif ARCH_32
1411                         return new nfloat ((float)v.v);
1412 #else
1413                         return new nfloat ((double)v.v);
1414 #endif
1415                 }
1416
1417                 public static explicit operator nuint (IntPtr v)
1418                 {
1419 #if NINT_JIT_OPTIMIZED
1420                         throw new NotImplementedException ();
1421 #elif ARCH_32
1422                         return new nuint (*((uint *)&v));
1423 #else
1424                         return new nuint (*((ulong *)&v));
1425 #endif
1426                 }
1427
1428                 public static explicit operator IntPtr (nuint v)
1429                 {
1430 #if NINT_JIT_OPTIMIZED
1431                         throw new NotImplementedException ();
1432 #elif ARCH_32
1433                         return *((IntPtr *)&v.v);
1434 #else
1435                         return *((IntPtr *)&v.v);
1436 #endif
1437                 }
1438
1439                 public static explicit operator nuint (sbyte v)
1440                 {
1441 #if NINT_JIT_OPTIMIZED
1442                         throw new NotImplementedException ();
1443 #elif ARCH_32
1444                         return new nuint ((uint)v);
1445 #else
1446                         return new nuint ((ulong)v);
1447 #endif
1448                 }
1449
1450                 public static explicit operator sbyte (nuint v)
1451                 {
1452 #if NINT_JIT_OPTIMIZED
1453                         throw new NotImplementedException ();
1454 #elif ARCH_32
1455                         return (sbyte)v.v;
1456 #else
1457                         return (sbyte)v.v;
1458 #endif
1459                 }
1460
1461                 public static implicit operator nuint (byte v)
1462                 {
1463 #if NINT_JIT_OPTIMIZED
1464                         throw new NotImplementedException ();
1465 #elif ARCH_32
1466                         return new nuint ((uint)v);
1467 #else
1468                         return new nuint ((ulong)v);
1469 #endif
1470                 }
1471
1472                 public static explicit operator byte (nuint v)
1473                 {
1474 #if NINT_JIT_OPTIMIZED
1475                         throw new NotImplementedException ();
1476 #elif ARCH_32
1477                         return (byte)v.v;
1478 #else
1479                         return (byte)v.v;
1480 #endif
1481                 }
1482
1483                 public static implicit operator nuint (char v)
1484                 {
1485 #if NINT_JIT_OPTIMIZED
1486                         throw new NotImplementedException ();
1487 #elif ARCH_32
1488                         return new nuint ((uint)v);
1489 #else
1490                         return new nuint ((ulong)v);
1491 #endif
1492                 }
1493
1494                 public static explicit operator char (nuint v)
1495                 {
1496 #if NINT_JIT_OPTIMIZED
1497                         throw new NotImplementedException ();
1498 #elif ARCH_32
1499                         return (char)v.v;
1500 #else
1501                         return (char)v.v;
1502 #endif
1503                 }
1504
1505                 public static explicit operator nuint (short v)
1506                 {
1507 #if NINT_JIT_OPTIMIZED
1508                         throw new NotImplementedException ();
1509 #elif ARCH_32
1510                         return new nuint ((uint)v);
1511 #else
1512                         return new nuint ((ulong)v);
1513 #endif
1514                 }
1515
1516                 public static explicit operator short (nuint v)
1517                 {
1518 #if NINT_JIT_OPTIMIZED
1519                         throw new NotImplementedException ();
1520 #elif ARCH_32
1521                         return (short)v.v;
1522 #else
1523                         return (short)v.v;
1524 #endif
1525                 }
1526
1527                 public static implicit operator nuint (ushort v)
1528                 {
1529 #if NINT_JIT_OPTIMIZED
1530                         throw new NotImplementedException ();
1531 #elif ARCH_32
1532                         return new nuint ((uint)v);
1533 #else
1534                         return new nuint ((ulong)v);
1535 #endif
1536                 }
1537
1538                 public static explicit operator ushort (nuint v)
1539                 {
1540 #if NINT_JIT_OPTIMIZED
1541                         throw new NotImplementedException ();
1542 #elif ARCH_32
1543                         return (ushort)v.v;
1544 #else
1545                         return (ushort)v.v;
1546 #endif
1547                 }
1548
1549                 public static explicit operator nuint (int v)
1550                 {
1551 #if NINT_JIT_OPTIMIZED
1552                         throw new NotImplementedException ();
1553 #elif ARCH_32
1554                         return new nuint ((uint)v);
1555 #else
1556                         return new nuint ((ulong)v);
1557 #endif
1558                 }
1559
1560                 public static explicit operator int (nuint v)
1561                 {
1562 #if NINT_JIT_OPTIMIZED
1563                         throw new NotImplementedException ();
1564 #elif ARCH_32
1565                         return (int)v.v;
1566 #else
1567                         return (int)v.v;
1568 #endif
1569                 }
1570
1571                 public static implicit operator nuint (uint v)
1572                 {
1573 #if NINT_JIT_OPTIMIZED
1574                         throw new NotImplementedException ();
1575 #elif ARCH_32
1576                         return new nuint ((uint)v);
1577 #else
1578                         return new nuint ((ulong)v);
1579 #endif
1580                 }
1581
1582                 public static explicit operator uint (nuint v)
1583                 {
1584 #if NINT_JIT_OPTIMIZED
1585                         throw new NotImplementedException ();
1586 #elif ARCH_32
1587                         return (uint)v.v;
1588 #else
1589                         return (uint)v.v;
1590 #endif
1591                 }
1592
1593                 public static explicit operator nuint (long v)
1594                 {
1595 #if NINT_JIT_OPTIMIZED
1596                         throw new NotImplementedException ();
1597 #elif ARCH_32
1598                         return new nuint ((uint)v);
1599 #else
1600                         return new nuint ((ulong)v);
1601 #endif
1602                 }
1603
1604                 public static explicit operator long (nuint v)
1605                 {
1606 #if NINT_JIT_OPTIMIZED
1607                         throw new NotImplementedException ();
1608 #elif ARCH_32
1609                         return (long)v.v;
1610 #else
1611                         return (long)v.v;
1612 #endif
1613                 }
1614
1615                 public static explicit operator nuint (ulong v)
1616                 {
1617 #if NINT_JIT_OPTIMIZED
1618                         throw new NotImplementedException ();
1619 #elif ARCH_32
1620                         return new nuint ((uint)v);
1621 #else
1622                         return new nuint ((ulong)v);
1623 #endif
1624                 }
1625
1626                 public static implicit operator ulong (nuint v)
1627                 {
1628 #if NINT_JIT_OPTIMIZED
1629                         throw new NotImplementedException ();
1630 #elif ARCH_32
1631                         return (ulong)v.v;
1632 #else
1633                         return (ulong)v.v;
1634 #endif
1635                 }
1636
1637                 public static explicit operator nuint (float v)
1638                 {
1639 #if NINT_JIT_OPTIMIZED
1640                         throw new NotImplementedException ();
1641 #elif ARCH_32
1642                         return new nuint ((uint)v);
1643 #else
1644                         return new nuint ((ulong)v);
1645 #endif
1646                 }
1647
1648                 public static implicit operator float (nuint v)
1649                 {
1650 #if NINT_JIT_OPTIMIZED
1651                         throw new NotImplementedException ();
1652 #elif ARCH_32
1653                         return (float)v.v;
1654 #else
1655                         return (float)v.v;
1656 #endif
1657                 }
1658
1659                 public static explicit operator nuint (double v)
1660                 {
1661 #if NINT_JIT_OPTIMIZED
1662                         throw new NotImplementedException ();
1663 #elif ARCH_32
1664                         return new nuint ((uint)v);
1665 #else
1666                         return new nuint ((ulong)v);
1667 #endif
1668                 }
1669
1670                 public static implicit operator double (nuint v)
1671                 {
1672 #if NINT_JIT_OPTIMIZED
1673                         throw new NotImplementedException ();
1674 #elif ARCH_32
1675                         return (double)v.v;
1676 #else
1677                         return (double)v.v;
1678 #endif
1679                 }
1680
1681                 public static explicit operator nuint (decimal v)
1682                 {
1683 #if NINT_JIT_OPTIMIZED
1684                         throw new NotImplementedException ();
1685 #elif ARCH_32
1686                         return new nuint ((uint)v);
1687 #else
1688                         return new nuint ((ulong)v);
1689 #endif
1690                 }
1691
1692                 public static implicit operator decimal (nuint v)
1693                 {
1694 #if NINT_JIT_OPTIMIZED
1695                         throw new NotImplementedException ();
1696 #elif ARCH_32
1697                         return (decimal)v.v;
1698 #else
1699                         return (decimal)v.v;
1700 #endif
1701                 }
1702
1703 #if NINT_JIT_OPTIMIZED
1704                 public static nuint operator + (nuint v) { throw new NotImplementedException (); }
1705                 public static nuint operator ~ (nuint v) { throw new NotImplementedException (); }
1706 #else
1707                 public static nuint operator + (nuint v) { return new nuint (+v.v); }
1708                 public static nuint operator ~ (nuint v) { return new nuint (~v.v); }
1709 #endif
1710
1711 #if NINT_JIT_OPTIMIZED
1712                 public static nuint operator ++ (nuint v) { throw new NotImplementedException (); }
1713                 public static nuint operator -- (nuint v) { throw new NotImplementedException (); }
1714 #else
1715                 public static nuint operator ++ (nuint v) { return new nuint (v.v + 1); }
1716                 public static nuint operator -- (nuint v) { return new nuint (v.v - 1); }
1717 #endif
1718
1719 #if NINT_JIT_OPTIMIZED
1720                 public static nuint operator + (nuint l, nuint r) { throw new NotImplementedException (); }
1721                 public static nuint operator - (nuint l, nuint r) { throw new NotImplementedException (); }
1722                 public static nuint operator * (nuint l, nuint r) { throw new NotImplementedException (); }
1723                 public static nuint operator / (nuint l, nuint r) { throw new NotImplementedException (); }
1724                 public static nuint operator % (nuint l, nuint r) { throw new NotImplementedException (); }
1725                 public static nuint operator & (nuint l, nuint r) { throw new NotImplementedException (); }
1726                 public static nuint operator | (nuint l, nuint r) { throw new NotImplementedException (); }
1727                 public static nuint operator ^ (nuint l, nuint r) { throw new NotImplementedException (); }
1728
1729                 public static nuint operator << (nuint l, int r) { throw new NotImplementedException (); }
1730                 public static nuint operator >> (nuint l, int r) { throw new NotImplementedException (); }
1731 #else
1732                 public static nuint operator + (nuint l, nuint r) { return new nuint (l.v + r.v); }
1733                 public static nuint operator - (nuint l, nuint r) { return new nuint (l.v - r.v); }
1734                 public static nuint operator * (nuint l, nuint r) { return new nuint (l.v * r.v); }
1735                 public static nuint operator / (nuint l, nuint r) { return new nuint (l.v / r.v); }
1736                 public static nuint operator % (nuint l, nuint r) { return new nuint (l.v % r.v); }
1737                 public static nuint operator & (nuint l, nuint r) { return new nuint (l.v & r.v); }
1738                 public static nuint operator | (nuint l, nuint r) { return new nuint (l.v | r.v); }
1739                 public static nuint operator ^ (nuint l, nuint r) { return new nuint (l.v ^ r.v); }
1740
1741                 public static nuint operator << (nuint l, int r) { return new nuint (l.v << r); }
1742                 public static nuint operator >> (nuint l, int r) { return new nuint (l.v >> r); }
1743 #endif
1744
1745 #if NINT_JIT_OPTIMIZED
1746                 public static bool operator == (nuint l, nuint r) { throw new NotImplementedException (); }
1747                 public static bool operator != (nuint l, nuint r) { throw new NotImplementedException (); }
1748                 public static bool operator <  (nuint l, nuint r) { throw new NotImplementedException (); }
1749                 public static bool operator >  (nuint l, nuint r) { throw new NotImplementedException (); }
1750                 public static bool operator <= (nuint l, nuint r) { throw new NotImplementedException (); }
1751                 public static bool operator >= (nuint l, nuint r) { throw new NotImplementedException (); }
1752 #else
1753                 public static bool operator == (nuint l, nuint r) { return l.v == r.v; }
1754                 public static bool operator != (nuint l, nuint r) { return l.v != r.v; }
1755                 public static bool operator <  (nuint l, nuint r) { return l.v < r.v; }
1756                 public static bool operator >  (nuint l, nuint r) { return l.v > r.v; }
1757                 public static bool operator <= (nuint l, nuint r) { return l.v <= r.v; }
1758                 public static bool operator >= (nuint l, nuint r) { return l.v >= r.v; }
1759 #endif
1760
1761                 public int CompareTo (nuint value) { return v.CompareTo (value.v); }
1762                 public int CompareTo (object value)
1763                 {
1764                         if (value is nuint)
1765                                 return v.CompareTo (((nuint) value).v);
1766                         return v.CompareTo (value);
1767                 }
1768                 public bool Equals (nuint obj) { return v.Equals (obj.v); }
1769                 public override bool Equals (object obj)
1770                 {
1771                         if (obj is nuint)
1772                                 return v.Equals (((nuint) obj).v);
1773                         return v.Equals (obj);
1774                 }
1775                 public override int GetHashCode () { return v.GetHashCode (); }
1776
1777 #if ARCH_32
1778                 public static nuint Parse (string s, IFormatProvider provider) { return (nuint)UInt32.Parse (s, provider); }
1779                 public static nuint Parse (string s, NumberStyles style) { return (nuint)UInt32.Parse (s, style); }
1780                 public static nuint Parse (string s) { return (nuint)UInt32.Parse (s); }
1781                 public static nuint Parse (string s, NumberStyles style, IFormatProvider provider) {
1782                         return (nuint)UInt32.Parse (s, style, provider);
1783                 }
1784
1785                 public static bool TryParse (string s, out nuint result)
1786                 {
1787                         UInt32 v;
1788                         var r = UInt32.TryParse (s, out v);
1789                         result = (nuint)v;
1790                         return r;
1791                 }
1792
1793                 public static bool TryParse (string s, NumberStyles style, IFormatProvider provider, out nuint result)
1794                 {
1795                         UInt32 v;
1796                         var r = UInt32.TryParse (s, style, provider, out v);
1797                         result = (nuint)v;
1798                         return r;
1799                 }
1800 #else
1801                 public static nuint Parse (string s, IFormatProvider provider) { return (nuint)UInt64.Parse (s, provider); }
1802                 public static nuint Parse (string s, NumberStyles style) { return (nuint)UInt64.Parse (s, style); }
1803                 public static nuint Parse (string s) { return (nuint)UInt64.Parse (s); }
1804                 public static nuint Parse (string s, NumberStyles style, IFormatProvider provider) {
1805                         return (nuint)UInt64.Parse (s, style, provider);
1806                 }
1807
1808                 public static bool TryParse (string s, out nuint result)
1809                 {
1810                         UInt64 v;
1811                         var r = UInt64.TryParse (s, out v);
1812                         result = (nuint)v;
1813                         return r;
1814                 }
1815
1816                 public static bool TryParse (string s, NumberStyles style, IFormatProvider provider, out nuint result)
1817                 {
1818                         UInt64 v;
1819                         var r = UInt64.TryParse (s, style, provider, out v);
1820                         result = (nuint)v;
1821                         return r;
1822                 }
1823 #endif
1824
1825                 public override string ToString () { return v.ToString (); }
1826                 public string ToString (IFormatProvider provider) { return v.ToString (provider); }
1827                 public string ToString (string format) { return v.ToString (format); }
1828                 public string ToString (string format, IFormatProvider provider) { return v.ToString (format, provider); }
1829
1830                 public TypeCode GetTypeCode () { return v.GetTypeCode (); }
1831
1832                 bool     IConvertible.ToBoolean  (IFormatProvider provider) { return ((IConvertible)v).ToBoolean (provider); }
1833                 byte     IConvertible.ToByte     (IFormatProvider provider) { return ((IConvertible)v).ToByte (provider); }
1834                 char     IConvertible.ToChar     (IFormatProvider provider) { return ((IConvertible)v).ToChar (provider); }
1835                 DateTime IConvertible.ToDateTime (IFormatProvider provider) { return ((IConvertible)v).ToDateTime (provider); }
1836                 decimal  IConvertible.ToDecimal  (IFormatProvider provider) { return ((IConvertible)v).ToDecimal (provider); }
1837                 double   IConvertible.ToDouble   (IFormatProvider provider) { return ((IConvertible)v).ToDouble (provider); }
1838                 short    IConvertible.ToInt16    (IFormatProvider provider) { return ((IConvertible)v).ToInt16 (provider); }
1839                 int      IConvertible.ToInt32    (IFormatProvider provider) { return ((IConvertible)v).ToInt32 (provider); }
1840                 long     IConvertible.ToInt64    (IFormatProvider provider) { return ((IConvertible)v).ToInt64 (provider); }
1841                 sbyte    IConvertible.ToSByte    (IFormatProvider provider) { return ((IConvertible)v).ToSByte (provider); }
1842                 float    IConvertible.ToSingle   (IFormatProvider provider) { return ((IConvertible)v).ToSingle (provider); }
1843                 ushort   IConvertible.ToUInt16   (IFormatProvider provider) { return ((IConvertible)v).ToUInt16 (provider); }
1844                 uint     IConvertible.ToUInt32   (IFormatProvider provider) { return ((IConvertible)v).ToUInt32 (provider); }
1845                 ulong    IConvertible.ToUInt64   (IFormatProvider provider) { return ((IConvertible)v).ToUInt64 (provider); }
1846
1847                 object IConvertible.ToType (Type targetType, IFormatProvider provider) {
1848                         return ((IConvertible)v).ToType (targetType, provider);
1849                 }
1850
1851                 public static void CopyArray (IntPtr source, nuint [] destination, int startIndex, int length)
1852                 {
1853                         if (source == IntPtr.Zero)
1854                                 throw new ArgumentNullException ("source");
1855                         if (destination == null)
1856                                 throw new ArgumentNullException ("destination");
1857                         if (destination.Rank != 1)
1858                                 throw new ArgumentException ("destination", "array is multi-dimensional");
1859                         if (startIndex < 0)
1860                                 throw new ArgumentException ("startIndex", "must be >= 0");
1861                         if (length < 0)
1862                                 throw new ArgumentException ("length", "must be >= 0");
1863                         if (startIndex + length > destination.Length)
1864                                 throw new ArgumentException ("length", "startIndex + length > destination.Length");
1865
1866                         for (int i = 0; i < length; i++)
1867                                 destination [i + startIndex] = (nuint)Marshal.ReadIntPtr (source, i * nuint.Size);
1868                 }
1869
1870                 public static void CopyArray (nuint [] source, int startIndex, IntPtr destination, int length)
1871                 {
1872                         if (source == null)
1873                                 throw new ArgumentNullException ("source");
1874                         if (destination == IntPtr.Zero)
1875                                 throw new ArgumentNullException ("destination");
1876                         if (source.Rank != 1)
1877                                 throw new ArgumentException ("source", "array is multi-dimensional");
1878                         if (startIndex < 0)
1879                                 throw new ArgumentException ("startIndex", "must be >= 0");
1880                         if (length < 0)
1881                                 throw new ArgumentException ("length", "must be >= 0");
1882                         if (startIndex + length > source.Length)
1883                                 throw new ArgumentException ("length", "startIndex + length > source.Length");
1884
1885                         for (int i = 0; i < length; i++)
1886                                 Marshal.WriteIntPtr (destination, i * nuint.Size, (IntPtr)source [i + startIndex]);
1887                 }
1888         }
1889         [Serializable]
1890         [DebuggerDisplay ("{v,nq}")]
1891         public unsafe struct nfloat : IFormattable, IConvertible, IComparable, IComparable<nfloat>, IEquatable <nfloat>
1892         {
1893                 internal nfloat (nfloat v) { this.v = v.v; }
1894                 public nfloat (Single v) { this.v = v; }
1895
1896 #if ARCH_32
1897                 public static readonly int Size = 4;
1898
1899                 public static readonly nfloat MaxValue = Single.MaxValue;
1900                 public static readonly nfloat MinValue = Single.MinValue;
1901                 public static readonly nfloat Epsilon = (nfloat)Single.Epsilon;
1902                 public static readonly nfloat NaN = (nfloat)Single.NaN;
1903                 public static readonly nfloat NegativeInfinity = (nfloat)Single.NegativeInfinity;
1904                 public static readonly nfloat PositiveInfinity = (nfloat)Single.PositiveInfinity;
1905
1906                 [DebuggerBrowsable (DebuggerBrowsableState.Never)]
1907                 internal Single v;
1908
1909                 public nfloat (Double v) { this.v = (Single)v; }
1910 #else
1911                 public static readonly int Size = 8;
1912
1913                 public static readonly nfloat MaxValue = (nfloat) Double.MaxValue; // 64-bit only codepath
1914                 public static readonly nfloat MinValue = (nfloat) Double.MinValue; // 64-bit only codepath
1915                 public static readonly nfloat Epsilon = (nfloat)Double.Epsilon;
1916                 public static readonly nfloat NaN = (nfloat)Double.NaN;
1917                 public static readonly nfloat NegativeInfinity = (nfloat)Double.NegativeInfinity;
1918                 public static readonly nfloat PositiveInfinity = (nfloat)Double.PositiveInfinity;
1919
1920                 [DebuggerBrowsable (DebuggerBrowsableState.Never)]
1921                 internal Double v;
1922
1923                 public nfloat (Double v) { this.v = v; }
1924 #endif
1925
1926                 public static explicit operator nfloat (IntPtr v)
1927                 {
1928 #if NINT_JIT_OPTIMIZED
1929                         throw new NotImplementedException ();
1930 #elif ARCH_32
1931                         return new nfloat (*((float *)&v));
1932 #else
1933                         return new nfloat (*((double *)&v));
1934 #endif
1935                 }
1936
1937                 public static explicit operator IntPtr (nfloat v)
1938                 {
1939 #if NINT_JIT_OPTIMIZED
1940                         throw new NotImplementedException ();
1941 #elif ARCH_32
1942                         return *((IntPtr *)&v.v);
1943 #else
1944                         return *((IntPtr *)&v.v);
1945 #endif
1946                 }
1947
1948                 public static implicit operator nfloat (sbyte v)
1949                 {
1950 #if NINT_JIT_OPTIMIZED
1951                         throw new NotImplementedException ();
1952 #elif ARCH_32
1953                         return new nfloat ((float)v);
1954 #else
1955                         return new nfloat ((double)v);
1956 #endif
1957                 }
1958
1959                 public static explicit operator sbyte (nfloat v)
1960                 {
1961 #if NINT_JIT_OPTIMIZED
1962                         throw new NotImplementedException ();
1963 #elif ARCH_32
1964                         return (sbyte)v.v;
1965 #else
1966                         return (sbyte)v.v;
1967 #endif
1968                 }
1969
1970                 public static implicit operator nfloat (byte v)
1971                 {
1972 #if NINT_JIT_OPTIMIZED
1973                         throw new NotImplementedException ();
1974 #elif ARCH_32
1975                         return new nfloat ((float)v);
1976 #else
1977                         return new nfloat ((double)v);
1978 #endif
1979                 }
1980
1981                 public static explicit operator byte (nfloat v)
1982                 {
1983 #if NINT_JIT_OPTIMIZED
1984                         throw new NotImplementedException ();
1985 #elif ARCH_32
1986                         return (byte)v.v;
1987 #else
1988                         return (byte)v.v;
1989 #endif
1990                 }
1991
1992                 public static implicit operator nfloat (char v)
1993                 {
1994 #if NINT_JIT_OPTIMIZED
1995                         throw new NotImplementedException ();
1996 #elif ARCH_32
1997                         return new nfloat ((float)v);
1998 #else
1999                         return new nfloat ((double)v);
2000 #endif
2001                 }
2002
2003                 public static explicit operator char (nfloat v)
2004                 {
2005 #if NINT_JIT_OPTIMIZED
2006                         throw new NotImplementedException ();
2007 #elif ARCH_32
2008                         return (char)v.v;
2009 #else
2010                         return (char)v.v;
2011 #endif
2012                 }
2013
2014                 public static implicit operator nfloat (short v)
2015                 {
2016 #if NINT_JIT_OPTIMIZED
2017                         throw new NotImplementedException ();
2018 #elif ARCH_32
2019                         return new nfloat ((float)v);
2020 #else
2021                         return new nfloat ((double)v);
2022 #endif
2023                 }
2024
2025                 public static explicit operator short (nfloat v)
2026                 {
2027 #if NINT_JIT_OPTIMIZED
2028                         throw new NotImplementedException ();
2029 #elif ARCH_32
2030                         return (short)v.v;
2031 #else
2032                         return (short)v.v;
2033 #endif
2034                 }
2035
2036                 public static implicit operator nfloat (ushort v)
2037                 {
2038 #if NINT_JIT_OPTIMIZED
2039                         throw new NotImplementedException ();
2040 #elif ARCH_32
2041                         return new nfloat ((float)v);
2042 #else
2043                         return new nfloat ((double)v);
2044 #endif
2045                 }
2046
2047                 public static explicit operator ushort (nfloat v)
2048                 {
2049 #if NINT_JIT_OPTIMIZED
2050                         throw new NotImplementedException ();
2051 #elif ARCH_32
2052                         return (ushort)v.v;
2053 #else
2054                         return (ushort)v.v;
2055 #endif
2056                 }
2057
2058                 public static implicit operator nfloat (int v)
2059                 {
2060 #if NINT_JIT_OPTIMIZED
2061                         throw new NotImplementedException ();
2062 #elif ARCH_32
2063                         return new nfloat ((float)v);
2064 #else
2065                         return new nfloat ((double)v);
2066 #endif
2067                 }
2068
2069                 public static explicit operator int (nfloat v)
2070                 {
2071 #if NINT_JIT_OPTIMIZED
2072                         throw new NotImplementedException ();
2073 #elif ARCH_32
2074                         return (int)v.v;
2075 #else
2076                         return (int)v.v;
2077 #endif
2078                 }
2079
2080                 public static implicit operator nfloat (uint v)
2081                 {
2082 #if NINT_JIT_OPTIMIZED
2083                         throw new NotImplementedException ();
2084 #elif ARCH_32
2085                         return new nfloat ((float)v);
2086 #else
2087                         return new nfloat ((double)v);
2088 #endif
2089                 }
2090
2091                 public static explicit operator uint (nfloat v)
2092                 {
2093 #if NINT_JIT_OPTIMIZED
2094                         throw new NotImplementedException ();
2095 #elif ARCH_32
2096                         return (uint)v.v;
2097 #else
2098                         return (uint)v.v;
2099 #endif
2100                 }
2101
2102                 public static implicit operator nfloat (long v)
2103                 {
2104 #if NINT_JIT_OPTIMIZED
2105                         throw new NotImplementedException ();
2106 #elif ARCH_32
2107                         return new nfloat ((float)v);
2108 #else
2109                         return new nfloat ((double)v);
2110 #endif
2111                 }
2112
2113                 public static explicit operator long (nfloat v)
2114                 {
2115 #if NINT_JIT_OPTIMIZED
2116                         throw new NotImplementedException ();
2117 #elif ARCH_32
2118                         return (long)v.v;
2119 #else
2120                         return (long)v.v;
2121 #endif
2122                 }
2123
2124                 public static implicit operator nfloat (ulong v)
2125                 {
2126 #if NINT_JIT_OPTIMIZED
2127                         throw new NotImplementedException ();
2128 #elif ARCH_32
2129                         return new nfloat ((float)v);
2130 #else
2131                         return new nfloat ((double)v);
2132 #endif
2133                 }
2134
2135                 public static explicit operator ulong (nfloat v)
2136                 {
2137 #if NINT_JIT_OPTIMIZED
2138                         throw new NotImplementedException ();
2139 #elif ARCH_32
2140                         return (ulong)v.v;
2141 #else
2142                         return (ulong)v.v;
2143 #endif
2144                 }
2145
2146                 public static implicit operator nfloat (float v)
2147                 {
2148 #if NINT_JIT_OPTIMIZED
2149                         throw new NotImplementedException ();
2150 #elif ARCH_32
2151                         return new nfloat ((float)v);
2152 #else
2153                         return new nfloat ((double)v);
2154 #endif
2155                 }
2156
2157                 public static explicit operator float (nfloat v)
2158                 {
2159 #if NINT_JIT_OPTIMIZED
2160                         throw new NotImplementedException ();
2161 #elif ARCH_32
2162                         return (float)v.v;
2163 #else
2164                         return (float)v.v;
2165 #endif
2166                 }
2167
2168                 public static explicit operator nfloat (double v)
2169                 {
2170 #if NINT_JIT_OPTIMIZED
2171                         throw new NotImplementedException ();
2172 #elif ARCH_32
2173                         return new nfloat ((float)v);
2174 #else
2175                         return new nfloat ((double)v);
2176 #endif
2177                 }
2178
2179                 public static implicit operator double (nfloat v)
2180                 {
2181 #if NINT_JIT_OPTIMIZED
2182                         throw new NotImplementedException ();
2183 #elif ARCH_32
2184                         return (double)v.v;
2185 #else
2186                         return (double)v.v;
2187 #endif
2188                 }
2189
2190                 public static explicit operator nfloat (decimal v)
2191                 {
2192 #if NINT_JIT_OPTIMIZED
2193                         throw new NotImplementedException ();
2194 #elif ARCH_32
2195                         return new nfloat ((float)v);
2196 #else
2197                         return new nfloat ((double)v);
2198 #endif
2199                 }
2200
2201                 public static explicit operator decimal (nfloat v)
2202                 {
2203 #if NINT_JIT_OPTIMIZED
2204                         throw new NotImplementedException ();
2205 #elif ARCH_32
2206                         return (decimal)v.v;
2207 #else
2208                         return (decimal)v.v;
2209 #endif
2210                 }
2211
2212 #if NINT_JIT_OPTIMIZED
2213                 public static nfloat operator + (nfloat v) { throw new NotImplementedException (); }
2214                 public static nfloat operator - (nfloat v) { throw new NotImplementedException (); }
2215 #else
2216                 public static nfloat operator + (nfloat v) { return new nfloat (+v.v); }
2217                 public static nfloat operator - (nfloat v) { return new nfloat (-v.v); }
2218 #endif
2219
2220 #if NINT_JIT_OPTIMIZED
2221                 public static nfloat operator ++ (nfloat v) { throw new NotImplementedException (); }
2222                 public static nfloat operator -- (nfloat v) { throw new NotImplementedException (); }
2223 #else
2224                 public static nfloat operator ++ (nfloat v) { return new nfloat (v.v + 1); }
2225                 public static nfloat operator -- (nfloat v) { return new nfloat (v.v - 1); }
2226 #endif
2227
2228 #if NINT_JIT_OPTIMIZED
2229                 public static nfloat operator + (nfloat l, nfloat r) { throw new NotImplementedException (); }
2230                 public static nfloat operator - (nfloat l, nfloat r) { throw new NotImplementedException (); }
2231                 public static nfloat operator * (nfloat l, nfloat r) { throw new NotImplementedException (); }
2232                 public static nfloat operator / (nfloat l, nfloat r) { throw new NotImplementedException (); }
2233                 public static nfloat operator % (nfloat l, nfloat r) { throw new NotImplementedException (); }
2234 #else
2235                 public static nfloat operator + (nfloat l, nfloat r) { return new nfloat (l.v + r.v); }
2236                 public static nfloat operator - (nfloat l, nfloat r) { return new nfloat (l.v - r.v); }
2237                 public static nfloat operator * (nfloat l, nfloat r) { return new nfloat (l.v * r.v); }
2238                 public static nfloat operator / (nfloat l, nfloat r) { return new nfloat (l.v / r.v); }
2239                 public static nfloat operator % (nfloat l, nfloat r) { return new nfloat (l.v % r.v); }
2240 #endif
2241
2242 #if NINT_JIT_OPTIMIZED
2243                 public static bool operator == (nfloat l, nfloat r) { throw new NotImplementedException (); }
2244                 public static bool operator != (nfloat l, nfloat r) { throw new NotImplementedException (); }
2245                 public static bool operator <  (nfloat l, nfloat r) { throw new NotImplementedException (); }
2246                 public static bool operator >  (nfloat l, nfloat r) { throw new NotImplementedException (); }
2247                 public static bool operator <= (nfloat l, nfloat r) { throw new NotImplementedException (); }
2248                 public static bool operator >= (nfloat l, nfloat r) { throw new NotImplementedException (); }
2249 #else
2250                 public static bool operator == (nfloat l, nfloat r) { return l.v == r.v; }
2251                 public static bool operator != (nfloat l, nfloat r) { return l.v != r.v; }
2252                 public static bool operator <  (nfloat l, nfloat r) { return l.v < r.v; }
2253                 public static bool operator >  (nfloat l, nfloat r) { return l.v > r.v; }
2254                 public static bool operator <= (nfloat l, nfloat r) { return l.v <= r.v; }
2255                 public static bool operator >= (nfloat l, nfloat r) { return l.v >= r.v; }
2256 #endif
2257
2258                 public int CompareTo (nfloat value) { return v.CompareTo (value.v); }
2259                 public int CompareTo (object value)
2260                 {
2261                         if (value is nfloat)
2262                                 return v.CompareTo (((nfloat) value).v);
2263                         return v.CompareTo (value);
2264                 }
2265                 public bool Equals (nfloat obj) { return v.Equals (obj.v); }
2266                 public override bool Equals (object obj)
2267                 {
2268                         if (obj is nfloat)
2269                                 return v.Equals (((nfloat) obj).v);
2270                         return v.Equals (obj);
2271                 }
2272                 public override int GetHashCode () { return v.GetHashCode (); }
2273
2274 #if ARCH_32
2275                 public static bool IsNaN              (nfloat f) { return Single.IsNaN ((Single)f); }
2276                 public static bool IsInfinity         (nfloat f) { return Single.IsInfinity ((Single)f); }
2277                 public static bool IsPositiveInfinity (nfloat f) { return Single.IsPositiveInfinity ((Single)f); }
2278                 public static bool IsNegativeInfinity (nfloat f) { return Single.IsNegativeInfinity ((Single)f); }
2279
2280                 public static nfloat Parse (string s, IFormatProvider provider) { return (nfloat)Single.Parse (s, provider); }
2281                 public static nfloat Parse (string s, NumberStyles style) { return (nfloat)Single.Parse (s, style); }
2282                 public static nfloat Parse (string s) { return (nfloat)Single.Parse (s); }
2283                 public static nfloat Parse (string s, NumberStyles style, IFormatProvider provider) {
2284                         return (nfloat)Single.Parse (s, style, provider);
2285                 }
2286
2287                 public static bool TryParse (string s, out nfloat result)
2288                 {
2289                         Single v;
2290                         var r = Single.TryParse (s, out v);
2291                         result = (nfloat)v;
2292                         return r;
2293                 }
2294
2295                 public static bool TryParse (string s, NumberStyles style, IFormatProvider provider, out nfloat result)
2296                 {
2297                         Single v;
2298                         var r = Single.TryParse (s, style, provider, out v);
2299                         result = (nfloat)v;
2300                         return r;
2301                 }
2302 #else
2303                 public static bool IsNaN              (nfloat f) { return Double.IsNaN ((Double)f); }
2304                 public static bool IsInfinity         (nfloat f) { return Double.IsInfinity ((Double)f); }
2305                 public static bool IsPositiveInfinity (nfloat f) { return Double.IsPositiveInfinity ((Double)f); }
2306                 public static bool IsNegativeInfinity (nfloat f) { return Double.IsNegativeInfinity ((Double)f); }
2307
2308                 public static nfloat Parse (string s, IFormatProvider provider) { return (nfloat)Double.Parse (s, provider); }
2309                 public static nfloat Parse (string s, NumberStyles style) { return (nfloat)Double.Parse (s, style); }
2310                 public static nfloat Parse (string s) { return (nfloat)Double.Parse (s); }
2311                 public static nfloat Parse (string s, NumberStyles style, IFormatProvider provider) {
2312                         return (nfloat)Double.Parse (s, style, provider);
2313                 }
2314
2315                 public static bool TryParse (string s, out nfloat result)
2316                 {
2317                         Double v;
2318                         var r = Double.TryParse (s, out v);
2319                         result = (nfloat)v;
2320                         return r;
2321                 }
2322
2323                 public static bool TryParse (string s, NumberStyles style, IFormatProvider provider, out nfloat result)
2324                 {
2325                         Double v;
2326                         var r = Double.TryParse (s, style, provider, out v);
2327                         result = (nfloat)v;
2328                         return r;
2329                 }
2330 #endif
2331
2332                 public override string ToString () { return v.ToString (); }
2333                 public string ToString (IFormatProvider provider) { return v.ToString (provider); }
2334                 public string ToString (string format) { return v.ToString (format); }
2335                 public string ToString (string format, IFormatProvider provider) { return v.ToString (format, provider); }
2336
2337                 public TypeCode GetTypeCode () { return v.GetTypeCode (); }
2338
2339                 bool     IConvertible.ToBoolean  (IFormatProvider provider) { return ((IConvertible)v).ToBoolean (provider); }
2340                 byte     IConvertible.ToByte     (IFormatProvider provider) { return ((IConvertible)v).ToByte (provider); }
2341                 char     IConvertible.ToChar     (IFormatProvider provider) { return ((IConvertible)v).ToChar (provider); }
2342                 DateTime IConvertible.ToDateTime (IFormatProvider provider) { return ((IConvertible)v).ToDateTime (provider); }
2343                 decimal  IConvertible.ToDecimal  (IFormatProvider provider) { return ((IConvertible)v).ToDecimal (provider); }
2344                 double   IConvertible.ToDouble   (IFormatProvider provider) { return ((IConvertible)v).ToDouble (provider); }
2345                 short    IConvertible.ToInt16    (IFormatProvider provider) { return ((IConvertible)v).ToInt16 (provider); }
2346                 int      IConvertible.ToInt32    (IFormatProvider provider) { return ((IConvertible)v).ToInt32 (provider); }
2347                 long     IConvertible.ToInt64    (IFormatProvider provider) { return ((IConvertible)v).ToInt64 (provider); }
2348                 sbyte    IConvertible.ToSByte    (IFormatProvider provider) { return ((IConvertible)v).ToSByte (provider); }
2349                 float    IConvertible.ToSingle   (IFormatProvider provider) { return ((IConvertible)v).ToSingle (provider); }
2350                 ushort   IConvertible.ToUInt16   (IFormatProvider provider) { return ((IConvertible)v).ToUInt16 (provider); }
2351                 uint     IConvertible.ToUInt32   (IFormatProvider provider) { return ((IConvertible)v).ToUInt32 (provider); }
2352                 ulong    IConvertible.ToUInt64   (IFormatProvider provider) { return ((IConvertible)v).ToUInt64 (provider); }
2353
2354                 object IConvertible.ToType (Type targetType, IFormatProvider provider) {
2355                         return ((IConvertible)v).ToType (targetType, provider);
2356                 }
2357
2358                 public static void CopyArray (IntPtr source, nfloat [] destination, int startIndex, int length)
2359                 {
2360                         if (source == IntPtr.Zero)
2361                                 throw new ArgumentNullException ("source");
2362                         if (destination == null)
2363                                 throw new ArgumentNullException ("destination");
2364                         if (destination.Rank != 1)
2365                                 throw new ArgumentException ("destination", "array is multi-dimensional");
2366                         if (startIndex < 0)
2367                                 throw new ArgumentException ("startIndex", "must be >= 0");
2368                         if (length < 0)
2369                                 throw new ArgumentException ("length", "must be >= 0");
2370                         if (startIndex + length > destination.Length)
2371                                 throw new ArgumentException ("length", "startIndex + length > destination.Length");
2372
2373                         for (int i = 0; i < length; i++)
2374                                 destination [i + startIndex] = (nfloat)Marshal.ReadIntPtr (source, i * nfloat.Size);
2375                 }
2376
2377                 public static void CopyArray (nfloat [] source, int startIndex, IntPtr destination, int length)
2378                 {
2379                         if (source == null)
2380                                 throw new ArgumentNullException ("source");
2381                         if (destination == IntPtr.Zero)
2382                                 throw new ArgumentNullException ("destination");
2383                         if (source.Rank != 1)
2384                                 throw new ArgumentException ("source", "array is multi-dimensional");
2385                         if (startIndex < 0)
2386                                 throw new ArgumentException ("startIndex", "must be >= 0");
2387                         if (length < 0)
2388                                 throw new ArgumentException ("length", "must be >= 0");
2389                         if (startIndex + length > source.Length)
2390                                 throw new ArgumentException ("length", "startIndex + length > source.Length");
2391
2392                         for (int i = 0; i < length; i++)
2393                                 Marshal.WriteIntPtr (destination, i * nfloat.Size, (IntPtr)source [i + startIndex]);
2394                 }
2395         }
2396 }