Merge pull request #5714 from alexischr/update_bockbuild
[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 #if !__MOBILE__
796         public static int Main (String[] args) {
797                 return TestDriver.RunTests (typeof (BuiltinTests), args);
798         }
799 #endif
800 }
801
802
803 // !!! WARNING - GENERATED CODE - DO NOT EDIT !!!
804 //
805 // Generated by NativeTypes.tt, a T4 template.
806 //
807 // NativeTypes.cs: basic types with 32 or 64 bit sizes:
808 //
809 //   - nint
810 //   - nuint
811 //   - nfloat
812 //
813 // Authors:
814 //   Aaron Bockover <abock@xamarin.com>
815 //
816 // Copyright 2013 Xamarin, Inc. All rights reserved.
817 //
818
819 namespace System
820 {
821         [Serializable]
822         [DebuggerDisplay ("{v,nq}")]
823         public unsafe struct nint : IFormattable, IConvertible, IComparable, IComparable<nint>, IEquatable <nint>
824         {
825                 internal nint (nint v) { this.v = v.v; }
826                 public nint (Int32 v) { this.v = v; }
827
828 #if ARCH_32
829                 public static readonly int Size = 4;
830
831                 public static readonly nint MaxValue = Int32.MaxValue;
832                 public static readonly nint MinValue = Int32.MinValue;
833
834                 [DebuggerBrowsable (DebuggerBrowsableState.Never)]
835                 internal Int32 v;
836
837                 public nint (Int64 v) { this.v = (Int32)v; }
838 #else
839                 public static readonly int Size = 8;
840
841                 public static readonly nint MaxValue = (nint) Int64.MaxValue; // 64-bit only codepath
842                 public static readonly nint MinValue = (nint) Int64.MinValue; // 64-bit only codepath
843
844                 [DebuggerBrowsable (DebuggerBrowsableState.Never)]
845                 internal Int64 v;
846
847                 public nint (Int64 v) { this.v = v; }
848 #endif
849
850                 public static explicit operator nint (nuint v)
851                 {
852 #if NINT_JIT_OPTIMIZED
853                         throw new NotImplementedException ();
854 #elif ARCH_32
855                         return new nint ((int)v.v);
856 #else
857                         return new nint ((long)v.v);
858 #endif
859                 }
860
861                 public static explicit operator nuint (nint v)
862                 {
863 #if NINT_JIT_OPTIMIZED
864                         throw new NotImplementedException ();
865 #elif ARCH_32
866                         return new nuint ((uint)v.v);
867 #else
868                         return new nuint ((ulong)v.v);
869 #endif
870                 }
871
872                 public static explicit operator nint (nfloat v)
873                 {
874 #if NINT_JIT_OPTIMIZED
875                         throw new NotImplementedException ();
876 #elif ARCH_32
877                         return new nint ((int)v.v);
878 #else
879                         return new nint ((long)v.v);
880 #endif
881                 }
882
883                 public static implicit operator nfloat (nint v)
884                 {
885 #if NINT_JIT_OPTIMIZED
886                         throw new NotImplementedException ();
887 #elif ARCH_32
888                         return new nfloat ((float)v.v);
889 #else
890                         return new nfloat ((double)v.v);
891 #endif
892                 }
893
894                 public static explicit operator nint (IntPtr v)
895                 {
896 #if NINT_JIT_OPTIMIZED
897                         throw new NotImplementedException ();
898 #elif ARCH_32
899                         return new nint (*((int *)&v));
900 #else
901                         return new nint (*((long *)&v));
902 #endif
903                 }
904
905                 public static explicit operator IntPtr (nint v)
906                 {
907 #if NINT_JIT_OPTIMIZED
908                         throw new NotImplementedException ();
909 #elif ARCH_32
910                         return *((IntPtr *)&v.v);
911 #else
912                         return *((IntPtr *)&v.v);
913 #endif
914                 }
915
916                 public static implicit operator nint (sbyte v)
917                 {
918 #if NINT_JIT_OPTIMIZED
919                         throw new NotImplementedException ();
920 #elif ARCH_32
921                         return new nint ((int)v);
922 #else
923                         return new nint ((long)v);
924 #endif
925                 }
926
927                 public static explicit operator sbyte (nint v)
928                 {
929 #if NINT_JIT_OPTIMIZED
930                         throw new NotImplementedException ();
931 #elif ARCH_32
932                         return (sbyte)v.v;
933 #else
934                         return (sbyte)v.v;
935 #endif
936                 }
937
938                 public static implicit operator nint (byte v)
939                 {
940 #if NINT_JIT_OPTIMIZED
941                         throw new NotImplementedException ();
942 #elif ARCH_32
943                         return new nint ((int)v);
944 #else
945                         return new nint ((long)v);
946 #endif
947                 }
948
949                 public static explicit operator byte (nint v)
950                 {
951 #if NINT_JIT_OPTIMIZED
952                         throw new NotImplementedException ();
953 #elif ARCH_32
954                         return (byte)v.v;
955 #else
956                         return (byte)v.v;
957 #endif
958                 }
959
960                 public static implicit operator nint (char v)
961                 {
962 #if NINT_JIT_OPTIMIZED
963                         throw new NotImplementedException ();
964 #elif ARCH_32
965                         return new nint ((int)v);
966 #else
967                         return new nint ((long)v);
968 #endif
969                 }
970
971                 public static explicit operator char (nint v)
972                 {
973 #if NINT_JIT_OPTIMIZED
974                         throw new NotImplementedException ();
975 #elif ARCH_32
976                         return (char)v.v;
977 #else
978                         return (char)v.v;
979 #endif
980                 }
981
982                 public static implicit operator nint (short v)
983                 {
984 #if NINT_JIT_OPTIMIZED
985                         throw new NotImplementedException ();
986 #elif ARCH_32
987                         return new nint ((int)v);
988 #else
989                         return new nint ((long)v);
990 #endif
991                 }
992
993                 public static explicit operator short (nint v)
994                 {
995 #if NINT_JIT_OPTIMIZED
996                         throw new NotImplementedException ();
997 #elif ARCH_32
998                         return (short)v.v;
999 #else
1000                         return (short)v.v;
1001 #endif
1002                 }
1003
1004                 public static explicit operator nint (ushort v)
1005                 {
1006 #if NINT_JIT_OPTIMIZED
1007                         throw new NotImplementedException ();
1008 #elif ARCH_32
1009                         return new nint ((int)v);
1010 #else
1011                         return new nint ((long)v);
1012 #endif
1013                 }
1014
1015                 public static explicit operator ushort (nint v)
1016                 {
1017 #if NINT_JIT_OPTIMIZED
1018                         throw new NotImplementedException ();
1019 #elif ARCH_32
1020                         return (ushort)v.v;
1021 #else
1022                         return (ushort)v.v;
1023 #endif
1024                 }
1025
1026                 public static implicit operator nint (int v)
1027                 {
1028 #if NINT_JIT_OPTIMIZED
1029                         throw new NotImplementedException ();
1030 #elif ARCH_32
1031                         return new nint ((int)v);
1032 #else
1033                         return new nint ((long)v);
1034 #endif
1035                 }
1036
1037                 public static explicit operator int (nint v)
1038                 {
1039 #if NINT_JIT_OPTIMIZED
1040                         throw new NotImplementedException ();
1041 #elif ARCH_32
1042                         return (int)v.v;
1043 #else
1044                         return (int)v.v;
1045 #endif
1046                 }
1047
1048                 public static explicit operator nint (uint v)
1049                 {
1050 #if NINT_JIT_OPTIMIZED
1051                         throw new NotImplementedException ();
1052 #elif ARCH_32
1053                         return new nint ((int)v);
1054 #else
1055                         return new nint ((long)v);
1056 #endif
1057                 }
1058
1059                 public static explicit operator uint (nint v)
1060                 {
1061 #if NINT_JIT_OPTIMIZED
1062                         throw new NotImplementedException ();
1063 #elif ARCH_32
1064                         return (uint)v.v;
1065 #else
1066                         return (uint)v.v;
1067 #endif
1068                 }
1069
1070                 public static explicit operator nint (long v)
1071                 {
1072 #if NINT_JIT_OPTIMIZED
1073                         throw new NotImplementedException ();
1074 #elif ARCH_32
1075                         return new nint ((int)v);
1076 #else
1077                         return new nint ((long)v);
1078 #endif
1079                 }
1080
1081                 public static implicit operator long (nint v)
1082                 {
1083 #if NINT_JIT_OPTIMIZED
1084                         throw new NotImplementedException ();
1085 #elif ARCH_32
1086                         return (long)v.v;
1087 #else
1088                         return (long)v.v;
1089 #endif
1090                 }
1091
1092                 public static explicit operator nint (ulong v)
1093                 {
1094 #if NINT_JIT_OPTIMIZED
1095                         throw new NotImplementedException ();
1096 #elif ARCH_32
1097                         return new nint ((int)v);
1098 #else
1099                         return new nint ((long)v);
1100 #endif
1101                 }
1102
1103                 public static explicit operator ulong (nint v)
1104                 {
1105 #if NINT_JIT_OPTIMIZED
1106                         throw new NotImplementedException ();
1107 #elif ARCH_32
1108                         return (ulong)v.v;
1109 #else
1110                         return (ulong)v.v;
1111 #endif
1112                 }
1113
1114                 public static explicit operator nint (float v)
1115                 {
1116 #if NINT_JIT_OPTIMIZED
1117                         throw new NotImplementedException ();
1118 #elif ARCH_32
1119                         return new nint ((int)v);
1120 #else
1121                         return new nint ((long)v);
1122 #endif
1123                 }
1124
1125                 public static implicit operator float (nint v)
1126                 {
1127 #if NINT_JIT_OPTIMIZED
1128                         throw new NotImplementedException ();
1129 #elif ARCH_32
1130                         return (float)v.v;
1131 #else
1132                         return (float)v.v;
1133 #endif
1134                 }
1135
1136                 public static explicit operator nint (double v)
1137                 {
1138 #if NINT_JIT_OPTIMIZED
1139                         throw new NotImplementedException ();
1140 #elif ARCH_32
1141                         return new nint ((int)v);
1142 #else
1143                         return new nint ((long)v);
1144 #endif
1145                 }
1146
1147                 public static implicit operator double (nint v)
1148                 {
1149 #if NINT_JIT_OPTIMIZED
1150                         throw new NotImplementedException ();
1151 #elif ARCH_32
1152                         return (double)v.v;
1153 #else
1154                         return (double)v.v;
1155 #endif
1156                 }
1157
1158                 public static explicit operator nint (decimal v)
1159                 {
1160 #if NINT_JIT_OPTIMIZED
1161                         throw new NotImplementedException ();
1162 #elif ARCH_32
1163                         return new nint ((int)v);
1164 #else
1165                         return new nint ((long)v);
1166 #endif
1167                 }
1168
1169                 public static implicit operator decimal (nint v)
1170                 {
1171 #if NINT_JIT_OPTIMIZED
1172                         throw new NotImplementedException ();
1173 #elif ARCH_32
1174                         return (decimal)v.v;
1175 #else
1176                         return (decimal)v.v;
1177 #endif
1178                 }
1179
1180 #if NINT_JIT_OPTIMIZED
1181                 public static nint operator + (nint v) { throw new NotImplementedException (); }
1182                 public static nint operator - (nint v) { throw new NotImplementedException (); }
1183                 public static nint operator ~ (nint v) { throw new NotImplementedException (); }
1184 #else
1185                 public static nint operator + (nint v) { return new nint (+v.v); }
1186                 public static nint operator - (nint v) { return new nint (-v.v); }
1187                 public static nint operator ~ (nint v) { return new nint (~v.v); }
1188 #endif
1189
1190 #if NINT_JIT_OPTIMIZED
1191                 public static nint operator ++ (nint v) { throw new NotImplementedException (); }
1192                 public static nint operator -- (nint v) { throw new NotImplementedException (); }
1193 #else
1194                 public static nint operator ++ (nint v) { return new nint (v.v + 1); }
1195                 public static nint operator -- (nint v) { return new nint (v.v - 1); }
1196 #endif
1197
1198 #if NINT_JIT_OPTIMIZED
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                 public static nint operator | (nint l, nint r) { throw new NotImplementedException (); }
1206                 public static nint operator ^ (nint l, nint r) { throw new NotImplementedException (); }
1207
1208                 public static nint operator << (nint l, int r) { throw new NotImplementedException (); }
1209                 public static nint operator >> (nint l, int r) { throw new NotImplementedException (); }
1210 #else
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                 public static nint operator | (nint l, nint r) { return new nint (l.v | r.v); }
1218                 public static nint operator ^ (nint l, nint r) { return new nint (l.v ^ r.v); }
1219
1220                 public static nint operator << (nint l, int r) { return new nint (l.v << r); }
1221                 public static nint operator >> (nint l, int r) { return new nint (l.v >> r); }
1222 #endif
1223
1224 #if NINT_JIT_OPTIMIZED
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                 public static bool operator <= (nint l, nint r) { throw new NotImplementedException (); }
1230                 public static bool operator >= (nint l, nint r) { throw new NotImplementedException (); }
1231 #else
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                 public static bool operator <= (nint l, nint r) { return l.v <= r.v; }
1237                 public static bool operator >= (nint l, nint r) { return l.v >= r.v; }
1238 #endif
1239
1240                 public int CompareTo (nint value) { return v.CompareTo (value.v); }
1241                 public int CompareTo (object value)
1242                 {
1243                         if (value is nint)
1244                                 return v.CompareTo (((nint) value).v);
1245                         return v.CompareTo (value);
1246                 }
1247                 public bool Equals (nint obj) { return v.Equals (obj.v); }
1248                 public override bool Equals (object obj)
1249                 {
1250                         if (obj is nint)
1251                                 return v.Equals (((nint) obj).v);
1252                         return v.Equals (obj);
1253                 }
1254                 public override int GetHashCode () { return v.GetHashCode (); }
1255
1256 #if ARCH_32
1257                 public static nint Parse (string s, IFormatProvider provider) { return (nint)Int32.Parse (s, provider); }
1258                 public static nint Parse (string s, NumberStyles style) { return (nint)Int32.Parse (s, style); }
1259                 public static nint Parse (string s) { return (nint)Int32.Parse (s); }
1260                 public static nint Parse (string s, NumberStyles style, IFormatProvider provider) {
1261                         return (nint)Int32.Parse (s, style, provider);
1262                 }
1263
1264                 public static bool TryParse (string s, out nint result)
1265                 {
1266                         Int32 v;
1267                         var r = Int32.TryParse (s, out v);
1268                         result = (nint)v;
1269                         return r;
1270                 }
1271
1272                 public static bool TryParse (string s, NumberStyles style, IFormatProvider provider, out nint result)
1273                 {
1274                         Int32 v;
1275                         var r = Int32.TryParse (s, style, provider, out v);
1276                         result = (nint)v;
1277                         return r;
1278                 }
1279 #else
1280                 public static nint Parse (string s, IFormatProvider provider) { return (nint)Int64.Parse (s, provider); }
1281                 public static nint Parse (string s, NumberStyles style) { return (nint)Int64.Parse (s, style); }
1282                 public static nint Parse (string s) { return (nint)Int64.Parse (s); }
1283                 public static nint Parse (string s, NumberStyles style, IFormatProvider provider) {
1284                         return (nint)Int64.Parse (s, style, provider);
1285                 }
1286
1287                 public static bool TryParse (string s, out nint result)
1288                 {
1289                         Int64 v;
1290                         var r = Int64.TryParse (s, out v);
1291                         result = (nint)v;
1292                         return r;
1293                 }
1294
1295                 public static bool TryParse (string s, NumberStyles style, IFormatProvider provider, out nint result)
1296                 {
1297                         Int64 v;
1298                         var r = Int64.TryParse (s, style, provider, out v);
1299                         result = (nint)v;
1300                         return r;
1301                 }
1302 #endif
1303
1304                 public override string ToString () { return v.ToString (); }
1305                 public string ToString (IFormatProvider provider) { return v.ToString (provider); }
1306                 public string ToString (string format) { return v.ToString (format); }
1307                 public string ToString (string format, IFormatProvider provider) { return v.ToString (format, provider); }
1308
1309                 public TypeCode GetTypeCode () { return v.GetTypeCode (); }
1310
1311                 bool     IConvertible.ToBoolean  (IFormatProvider provider) { return ((IConvertible)v).ToBoolean (provider); }
1312                 byte     IConvertible.ToByte     (IFormatProvider provider) { return ((IConvertible)v).ToByte (provider); }
1313                 char     IConvertible.ToChar     (IFormatProvider provider) { return ((IConvertible)v).ToChar (provider); }
1314                 DateTime IConvertible.ToDateTime (IFormatProvider provider) { return ((IConvertible)v).ToDateTime (provider); }
1315                 decimal  IConvertible.ToDecimal  (IFormatProvider provider) { return ((IConvertible)v).ToDecimal (provider); }
1316                 double   IConvertible.ToDouble   (IFormatProvider provider) { return ((IConvertible)v).ToDouble (provider); }
1317                 short    IConvertible.ToInt16    (IFormatProvider provider) { return ((IConvertible)v).ToInt16 (provider); }
1318                 int      IConvertible.ToInt32    (IFormatProvider provider) { return ((IConvertible)v).ToInt32 (provider); }
1319                 long     IConvertible.ToInt64    (IFormatProvider provider) { return ((IConvertible)v).ToInt64 (provider); }
1320                 sbyte    IConvertible.ToSByte    (IFormatProvider provider) { return ((IConvertible)v).ToSByte (provider); }
1321                 float    IConvertible.ToSingle   (IFormatProvider provider) { return ((IConvertible)v).ToSingle (provider); }
1322                 ushort   IConvertible.ToUInt16   (IFormatProvider provider) { return ((IConvertible)v).ToUInt16 (provider); }
1323                 uint     IConvertible.ToUInt32   (IFormatProvider provider) { return ((IConvertible)v).ToUInt32 (provider); }
1324                 ulong    IConvertible.ToUInt64   (IFormatProvider provider) { return ((IConvertible)v).ToUInt64 (provider); }
1325
1326                 object IConvertible.ToType (Type targetType, IFormatProvider provider) {
1327                         return ((IConvertible)v).ToType (targetType, provider);
1328                 }
1329
1330                 public static void CopyArray (IntPtr source, nint [] destination, int startIndex, int length)
1331                 {
1332                         if (source == IntPtr.Zero)
1333                                 throw new ArgumentNullException ("source");
1334                         if (destination == null)
1335                                 throw new ArgumentNullException ("destination");
1336                         if (destination.Rank != 1)
1337                                 throw new ArgumentException ("destination", "array is multi-dimensional");
1338                         if (startIndex < 0)
1339                                 throw new ArgumentException ("startIndex", "must be >= 0");
1340                         if (length < 0)
1341                                 throw new ArgumentException ("length", "must be >= 0");
1342                         if (startIndex + length > destination.Length)
1343                                 throw new ArgumentException ("length", "startIndex + length > destination.Length");
1344
1345                         for (int i = 0; i < length; i++)
1346                                 destination [i + startIndex] = (nint)Marshal.ReadIntPtr (source, i * nint.Size);
1347                 }
1348
1349                 public static void CopyArray (nint [] source, int startIndex, IntPtr destination, int length)
1350                 {
1351                         if (source == null)
1352                                 throw new ArgumentNullException ("source");
1353                         if (destination == IntPtr.Zero)
1354                                 throw new ArgumentNullException ("destination");
1355                         if (source.Rank != 1)
1356                                 throw new ArgumentException ("source", "array is multi-dimensional");
1357                         if (startIndex < 0)
1358                                 throw new ArgumentException ("startIndex", "must be >= 0");
1359                         if (length < 0)
1360                                 throw new ArgumentException ("length", "must be >= 0");
1361                         if (startIndex + length > source.Length)
1362                                 throw new ArgumentException ("length", "startIndex + length > source.Length");
1363
1364                         for (int i = 0; i < length; i++)
1365                                 Marshal.WriteIntPtr (destination, i * nint.Size, (IntPtr)source [i + startIndex]);
1366                 }
1367         }
1368         [Serializable]
1369         [DebuggerDisplay ("{v,nq}")]
1370         public unsafe struct nuint : IFormattable, IConvertible, IComparable, IComparable<nuint>, IEquatable <nuint>
1371         {
1372                 internal nuint (nuint v) { this.v = v.v; }
1373                 public nuint (UInt32 v) { this.v = v; }
1374
1375 #if ARCH_32
1376                 public static readonly int Size = 4;
1377
1378                 public static readonly nuint MaxValue = UInt32.MaxValue;
1379                 public static readonly nuint MinValue = UInt32.MinValue;
1380
1381                 [DebuggerBrowsable (DebuggerBrowsableState.Never)]
1382                 internal UInt32 v;
1383
1384                 public nuint (UInt64 v) { this.v = (UInt32)v; }
1385 #else
1386                 public static readonly int Size = 8;
1387
1388                 public static readonly nuint MaxValue = (nuint) UInt64.MaxValue; // 64-bit only codepath
1389                 public static readonly nuint MinValue = (nuint) UInt64.MinValue; // 64-bit only codepath
1390
1391                 [DebuggerBrowsable (DebuggerBrowsableState.Never)]
1392                 internal UInt64 v;
1393
1394                 public nuint (UInt64 v) { this.v = v; }
1395 #endif
1396
1397                 public static explicit operator nuint (nfloat v)
1398                 {
1399 #if NINT_JIT_OPTIMIZED
1400                         throw new NotImplementedException ();
1401 #elif ARCH_32
1402                         return new nuint ((uint)v.v);
1403 #else
1404                         return new nuint ((ulong)v.v);
1405 #endif
1406                 }
1407
1408                 public static implicit operator nfloat (nuint v)
1409                 {
1410 #if NINT_JIT_OPTIMIZED
1411                         throw new NotImplementedException ();
1412 #elif ARCH_32
1413                         return new nfloat ((float)v.v);
1414 #else
1415                         return new nfloat ((double)v.v);
1416 #endif
1417                 }
1418
1419                 public static explicit operator nuint (IntPtr v)
1420                 {
1421 #if NINT_JIT_OPTIMIZED
1422                         throw new NotImplementedException ();
1423 #elif ARCH_32
1424                         return new nuint (*((uint *)&v));
1425 #else
1426                         return new nuint (*((ulong *)&v));
1427 #endif
1428                 }
1429
1430                 public static explicit operator IntPtr (nuint v)
1431                 {
1432 #if NINT_JIT_OPTIMIZED
1433                         throw new NotImplementedException ();
1434 #elif ARCH_32
1435                         return *((IntPtr *)&v.v);
1436 #else
1437                         return *((IntPtr *)&v.v);
1438 #endif
1439                 }
1440
1441                 public static explicit operator nuint (sbyte v)
1442                 {
1443 #if NINT_JIT_OPTIMIZED
1444                         throw new NotImplementedException ();
1445 #elif ARCH_32
1446                         return new nuint ((uint)v);
1447 #else
1448                         return new nuint ((ulong)v);
1449 #endif
1450                 }
1451
1452                 public static explicit operator sbyte (nuint v)
1453                 {
1454 #if NINT_JIT_OPTIMIZED
1455                         throw new NotImplementedException ();
1456 #elif ARCH_32
1457                         return (sbyte)v.v;
1458 #else
1459                         return (sbyte)v.v;
1460 #endif
1461                 }
1462
1463                 public static implicit operator nuint (byte v)
1464                 {
1465 #if NINT_JIT_OPTIMIZED
1466                         throw new NotImplementedException ();
1467 #elif ARCH_32
1468                         return new nuint ((uint)v);
1469 #else
1470                         return new nuint ((ulong)v);
1471 #endif
1472                 }
1473
1474                 public static explicit operator byte (nuint v)
1475                 {
1476 #if NINT_JIT_OPTIMIZED
1477                         throw new NotImplementedException ();
1478 #elif ARCH_32
1479                         return (byte)v.v;
1480 #else
1481                         return (byte)v.v;
1482 #endif
1483                 }
1484
1485                 public static implicit operator nuint (char v)
1486                 {
1487 #if NINT_JIT_OPTIMIZED
1488                         throw new NotImplementedException ();
1489 #elif ARCH_32
1490                         return new nuint ((uint)v);
1491 #else
1492                         return new nuint ((ulong)v);
1493 #endif
1494                 }
1495
1496                 public static explicit operator char (nuint v)
1497                 {
1498 #if NINT_JIT_OPTIMIZED
1499                         throw new NotImplementedException ();
1500 #elif ARCH_32
1501                         return (char)v.v;
1502 #else
1503                         return (char)v.v;
1504 #endif
1505                 }
1506
1507                 public static explicit operator nuint (short v)
1508                 {
1509 #if NINT_JIT_OPTIMIZED
1510                         throw new NotImplementedException ();
1511 #elif ARCH_32
1512                         return new nuint ((uint)v);
1513 #else
1514                         return new nuint ((ulong)v);
1515 #endif
1516                 }
1517
1518                 public static explicit operator short (nuint v)
1519                 {
1520 #if NINT_JIT_OPTIMIZED
1521                         throw new NotImplementedException ();
1522 #elif ARCH_32
1523                         return (short)v.v;
1524 #else
1525                         return (short)v.v;
1526 #endif
1527                 }
1528
1529                 public static implicit operator nuint (ushort v)
1530                 {
1531 #if NINT_JIT_OPTIMIZED
1532                         throw new NotImplementedException ();
1533 #elif ARCH_32
1534                         return new nuint ((uint)v);
1535 #else
1536                         return new nuint ((ulong)v);
1537 #endif
1538                 }
1539
1540                 public static explicit operator ushort (nuint v)
1541                 {
1542 #if NINT_JIT_OPTIMIZED
1543                         throw new NotImplementedException ();
1544 #elif ARCH_32
1545                         return (ushort)v.v;
1546 #else
1547                         return (ushort)v.v;
1548 #endif
1549                 }
1550
1551                 public static explicit operator nuint (int v)
1552                 {
1553 #if NINT_JIT_OPTIMIZED
1554                         throw new NotImplementedException ();
1555 #elif ARCH_32
1556                         return new nuint ((uint)v);
1557 #else
1558                         return new nuint ((ulong)v);
1559 #endif
1560                 }
1561
1562                 public static explicit operator int (nuint v)
1563                 {
1564 #if NINT_JIT_OPTIMIZED
1565                         throw new NotImplementedException ();
1566 #elif ARCH_32
1567                         return (int)v.v;
1568 #else
1569                         return (int)v.v;
1570 #endif
1571                 }
1572
1573                 public static implicit operator nuint (uint v)
1574                 {
1575 #if NINT_JIT_OPTIMIZED
1576                         throw new NotImplementedException ();
1577 #elif ARCH_32
1578                         return new nuint ((uint)v);
1579 #else
1580                         return new nuint ((ulong)v);
1581 #endif
1582                 }
1583
1584                 public static explicit operator uint (nuint v)
1585                 {
1586 #if NINT_JIT_OPTIMIZED
1587                         throw new NotImplementedException ();
1588 #elif ARCH_32
1589                         return (uint)v.v;
1590 #else
1591                         return (uint)v.v;
1592 #endif
1593                 }
1594
1595                 public static explicit operator nuint (long v)
1596                 {
1597 #if NINT_JIT_OPTIMIZED
1598                         throw new NotImplementedException ();
1599 #elif ARCH_32
1600                         return new nuint ((uint)v);
1601 #else
1602                         return new nuint ((ulong)v);
1603 #endif
1604                 }
1605
1606                 public static explicit operator long (nuint v)
1607                 {
1608 #if NINT_JIT_OPTIMIZED
1609                         throw new NotImplementedException ();
1610 #elif ARCH_32
1611                         return (long)v.v;
1612 #else
1613                         return (long)v.v;
1614 #endif
1615                 }
1616
1617                 public static explicit operator nuint (ulong v)
1618                 {
1619 #if NINT_JIT_OPTIMIZED
1620                         throw new NotImplementedException ();
1621 #elif ARCH_32
1622                         return new nuint ((uint)v);
1623 #else
1624                         return new nuint ((ulong)v);
1625 #endif
1626                 }
1627
1628                 public static implicit operator ulong (nuint v)
1629                 {
1630 #if NINT_JIT_OPTIMIZED
1631                         throw new NotImplementedException ();
1632 #elif ARCH_32
1633                         return (ulong)v.v;
1634 #else
1635                         return (ulong)v.v;
1636 #endif
1637                 }
1638
1639                 public static explicit operator nuint (float v)
1640                 {
1641 #if NINT_JIT_OPTIMIZED
1642                         throw new NotImplementedException ();
1643 #elif ARCH_32
1644                         return new nuint ((uint)v);
1645 #else
1646                         return new nuint ((ulong)v);
1647 #endif
1648                 }
1649
1650                 public static implicit operator float (nuint v)
1651                 {
1652 #if NINT_JIT_OPTIMIZED
1653                         throw new NotImplementedException ();
1654 #elif ARCH_32
1655                         return (float)v.v;
1656 #else
1657                         return (float)v.v;
1658 #endif
1659                 }
1660
1661                 public static explicit operator nuint (double v)
1662                 {
1663 #if NINT_JIT_OPTIMIZED
1664                         throw new NotImplementedException ();
1665 #elif ARCH_32
1666                         return new nuint ((uint)v);
1667 #else
1668                         return new nuint ((ulong)v);
1669 #endif
1670                 }
1671
1672                 public static implicit operator double (nuint v)
1673                 {
1674 #if NINT_JIT_OPTIMIZED
1675                         throw new NotImplementedException ();
1676 #elif ARCH_32
1677                         return (double)v.v;
1678 #else
1679                         return (double)v.v;
1680 #endif
1681                 }
1682
1683                 public static explicit operator nuint (decimal v)
1684                 {
1685 #if NINT_JIT_OPTIMIZED
1686                         throw new NotImplementedException ();
1687 #elif ARCH_32
1688                         return new nuint ((uint)v);
1689 #else
1690                         return new nuint ((ulong)v);
1691 #endif
1692                 }
1693
1694                 public static implicit operator decimal (nuint v)
1695                 {
1696 #if NINT_JIT_OPTIMIZED
1697                         throw new NotImplementedException ();
1698 #elif ARCH_32
1699                         return (decimal)v.v;
1700 #else
1701                         return (decimal)v.v;
1702 #endif
1703                 }
1704
1705 #if NINT_JIT_OPTIMIZED
1706                 public static nuint operator + (nuint v) { throw new NotImplementedException (); }
1707                 public static nuint operator ~ (nuint v) { throw new NotImplementedException (); }
1708 #else
1709                 public static nuint operator + (nuint v) { return new nuint (+v.v); }
1710                 public static nuint operator ~ (nuint v) { return new nuint (~v.v); }
1711 #endif
1712
1713 #if NINT_JIT_OPTIMIZED
1714                 public static nuint operator ++ (nuint v) { throw new NotImplementedException (); }
1715                 public static nuint operator -- (nuint v) { throw new NotImplementedException (); }
1716 #else
1717                 public static nuint operator ++ (nuint v) { return new nuint (v.v + 1); }
1718                 public static nuint operator -- (nuint v) { return new nuint (v.v - 1); }
1719 #endif
1720
1721 #if NINT_JIT_OPTIMIZED
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                 public static nuint operator | (nuint l, nuint r) { throw new NotImplementedException (); }
1729                 public static nuint operator ^ (nuint l, nuint r) { throw new NotImplementedException (); }
1730
1731                 public static nuint operator << (nuint l, int r) { throw new NotImplementedException (); }
1732                 public static nuint operator >> (nuint l, int r) { throw new NotImplementedException (); }
1733 #else
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                 public static nuint operator | (nuint l, nuint r) { return new nuint (l.v | r.v); }
1741                 public static nuint operator ^ (nuint l, nuint r) { return new nuint (l.v ^ r.v); }
1742
1743                 public static nuint operator << (nuint l, int r) { return new nuint (l.v << r); }
1744                 public static nuint operator >> (nuint l, int r) { return new nuint (l.v >> r); }
1745 #endif
1746
1747 #if NINT_JIT_OPTIMIZED
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                 public static bool operator <= (nuint l, nuint r) { throw new NotImplementedException (); }
1753                 public static bool operator >= (nuint l, nuint r) { throw new NotImplementedException (); }
1754 #else
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                 public static bool operator <= (nuint l, nuint r) { return l.v <= r.v; }
1760                 public static bool operator >= (nuint l, nuint r) { return l.v >= r.v; }
1761 #endif
1762
1763                 public int CompareTo (nuint value) { return v.CompareTo (value.v); }
1764                 public int CompareTo (object value)
1765                 {
1766                         if (value is nuint)
1767                                 return v.CompareTo (((nuint) value).v);
1768                         return v.CompareTo (value);
1769                 }
1770                 public bool Equals (nuint obj) { return v.Equals (obj.v); }
1771                 public override bool Equals (object obj)
1772                 {
1773                         if (obj is nuint)
1774                                 return v.Equals (((nuint) obj).v);
1775                         return v.Equals (obj);
1776                 }
1777                 public override int GetHashCode () { return v.GetHashCode (); }
1778
1779 #if ARCH_32
1780                 public static nuint Parse (string s, IFormatProvider provider) { return (nuint)UInt32.Parse (s, provider); }
1781                 public static nuint Parse (string s, NumberStyles style) { return (nuint)UInt32.Parse (s, style); }
1782                 public static nuint Parse (string s) { return (nuint)UInt32.Parse (s); }
1783                 public static nuint Parse (string s, NumberStyles style, IFormatProvider provider) {
1784                         return (nuint)UInt32.Parse (s, style, provider);
1785                 }
1786
1787                 public static bool TryParse (string s, out nuint result)
1788                 {
1789                         UInt32 v;
1790                         var r = UInt32.TryParse (s, out v);
1791                         result = (nuint)v;
1792                         return r;
1793                 }
1794
1795                 public static bool TryParse (string s, NumberStyles style, IFormatProvider provider, out nuint result)
1796                 {
1797                         UInt32 v;
1798                         var r = UInt32.TryParse (s, style, provider, out v);
1799                         result = (nuint)v;
1800                         return r;
1801                 }
1802 #else
1803                 public static nuint Parse (string s, IFormatProvider provider) { return (nuint)UInt64.Parse (s, provider); }
1804                 public static nuint Parse (string s, NumberStyles style) { return (nuint)UInt64.Parse (s, style); }
1805                 public static nuint Parse (string s) { return (nuint)UInt64.Parse (s); }
1806                 public static nuint Parse (string s, NumberStyles style, IFormatProvider provider) {
1807                         return (nuint)UInt64.Parse (s, style, provider);
1808                 }
1809
1810                 public static bool TryParse (string s, out nuint result)
1811                 {
1812                         UInt64 v;
1813                         var r = UInt64.TryParse (s, out v);
1814                         result = (nuint)v;
1815                         return r;
1816                 }
1817
1818                 public static bool TryParse (string s, NumberStyles style, IFormatProvider provider, out nuint result)
1819                 {
1820                         UInt64 v;
1821                         var r = UInt64.TryParse (s, style, provider, out v);
1822                         result = (nuint)v;
1823                         return r;
1824                 }
1825 #endif
1826
1827                 public override string ToString () { return v.ToString (); }
1828                 public string ToString (IFormatProvider provider) { return v.ToString (provider); }
1829                 public string ToString (string format) { return v.ToString (format); }
1830                 public string ToString (string format, IFormatProvider provider) { return v.ToString (format, provider); }
1831
1832                 public TypeCode GetTypeCode () { return v.GetTypeCode (); }
1833
1834                 bool     IConvertible.ToBoolean  (IFormatProvider provider) { return ((IConvertible)v).ToBoolean (provider); }
1835                 byte     IConvertible.ToByte     (IFormatProvider provider) { return ((IConvertible)v).ToByte (provider); }
1836                 char     IConvertible.ToChar     (IFormatProvider provider) { return ((IConvertible)v).ToChar (provider); }
1837                 DateTime IConvertible.ToDateTime (IFormatProvider provider) { return ((IConvertible)v).ToDateTime (provider); }
1838                 decimal  IConvertible.ToDecimal  (IFormatProvider provider) { return ((IConvertible)v).ToDecimal (provider); }
1839                 double   IConvertible.ToDouble   (IFormatProvider provider) { return ((IConvertible)v).ToDouble (provider); }
1840                 short    IConvertible.ToInt16    (IFormatProvider provider) { return ((IConvertible)v).ToInt16 (provider); }
1841                 int      IConvertible.ToInt32    (IFormatProvider provider) { return ((IConvertible)v).ToInt32 (provider); }
1842                 long     IConvertible.ToInt64    (IFormatProvider provider) { return ((IConvertible)v).ToInt64 (provider); }
1843                 sbyte    IConvertible.ToSByte    (IFormatProvider provider) { return ((IConvertible)v).ToSByte (provider); }
1844                 float    IConvertible.ToSingle   (IFormatProvider provider) { return ((IConvertible)v).ToSingle (provider); }
1845                 ushort   IConvertible.ToUInt16   (IFormatProvider provider) { return ((IConvertible)v).ToUInt16 (provider); }
1846                 uint     IConvertible.ToUInt32   (IFormatProvider provider) { return ((IConvertible)v).ToUInt32 (provider); }
1847                 ulong    IConvertible.ToUInt64   (IFormatProvider provider) { return ((IConvertible)v).ToUInt64 (provider); }
1848
1849                 object IConvertible.ToType (Type targetType, IFormatProvider provider) {
1850                         return ((IConvertible)v).ToType (targetType, provider);
1851                 }
1852
1853                 public static void CopyArray (IntPtr source, nuint [] destination, int startIndex, int length)
1854                 {
1855                         if (source == IntPtr.Zero)
1856                                 throw new ArgumentNullException ("source");
1857                         if (destination == null)
1858                                 throw new ArgumentNullException ("destination");
1859                         if (destination.Rank != 1)
1860                                 throw new ArgumentException ("destination", "array is multi-dimensional");
1861                         if (startIndex < 0)
1862                                 throw new ArgumentException ("startIndex", "must be >= 0");
1863                         if (length < 0)
1864                                 throw new ArgumentException ("length", "must be >= 0");
1865                         if (startIndex + length > destination.Length)
1866                                 throw new ArgumentException ("length", "startIndex + length > destination.Length");
1867
1868                         for (int i = 0; i < length; i++)
1869                                 destination [i + startIndex] = (nuint)Marshal.ReadIntPtr (source, i * nuint.Size);
1870                 }
1871
1872                 public static void CopyArray (nuint [] source, int startIndex, IntPtr destination, int length)
1873                 {
1874                         if (source == null)
1875                                 throw new ArgumentNullException ("source");
1876                         if (destination == IntPtr.Zero)
1877                                 throw new ArgumentNullException ("destination");
1878                         if (source.Rank != 1)
1879                                 throw new ArgumentException ("source", "array is multi-dimensional");
1880                         if (startIndex < 0)
1881                                 throw new ArgumentException ("startIndex", "must be >= 0");
1882                         if (length < 0)
1883                                 throw new ArgumentException ("length", "must be >= 0");
1884                         if (startIndex + length > source.Length)
1885                                 throw new ArgumentException ("length", "startIndex + length > source.Length");
1886
1887                         for (int i = 0; i < length; i++)
1888                                 Marshal.WriteIntPtr (destination, i * nuint.Size, (IntPtr)source [i + startIndex]);
1889                 }
1890         }
1891         [Serializable]
1892         [DebuggerDisplay ("{v,nq}")]
1893         public unsafe struct nfloat : IFormattable, IConvertible, IComparable, IComparable<nfloat>, IEquatable <nfloat>
1894         {
1895                 internal nfloat (nfloat v) { this.v = v.v; }
1896                 public nfloat (Single v) { this.v = v; }
1897
1898 #if ARCH_32
1899                 public static readonly int Size = 4;
1900
1901                 public static readonly nfloat MaxValue = Single.MaxValue;
1902                 public static readonly nfloat MinValue = Single.MinValue;
1903                 public static readonly nfloat Epsilon = (nfloat)Single.Epsilon;
1904                 public static readonly nfloat NaN = (nfloat)Single.NaN;
1905                 public static readonly nfloat NegativeInfinity = (nfloat)Single.NegativeInfinity;
1906                 public static readonly nfloat PositiveInfinity = (nfloat)Single.PositiveInfinity;
1907
1908                 [DebuggerBrowsable (DebuggerBrowsableState.Never)]
1909                 internal Single v;
1910
1911                 public nfloat (Double v) { this.v = (Single)v; }
1912 #else
1913                 public static readonly int Size = 8;
1914
1915                 public static readonly nfloat MaxValue = (nfloat) Double.MaxValue; // 64-bit only codepath
1916                 public static readonly nfloat MinValue = (nfloat) Double.MinValue; // 64-bit only codepath
1917                 public static readonly nfloat Epsilon = (nfloat)Double.Epsilon;
1918                 public static readonly nfloat NaN = (nfloat)Double.NaN;
1919                 public static readonly nfloat NegativeInfinity = (nfloat)Double.NegativeInfinity;
1920                 public static readonly nfloat PositiveInfinity = (nfloat)Double.PositiveInfinity;
1921
1922                 [DebuggerBrowsable (DebuggerBrowsableState.Never)]
1923                 internal Double v;
1924
1925                 public nfloat (Double v) { this.v = v; }
1926 #endif
1927
1928                 public static explicit operator nfloat (IntPtr v)
1929                 {
1930 #if NINT_JIT_OPTIMIZED
1931                         throw new NotImplementedException ();
1932 #elif ARCH_32
1933                         return new nfloat (*((float *)&v));
1934 #else
1935                         return new nfloat (*((double *)&v));
1936 #endif
1937                 }
1938
1939                 public static explicit operator IntPtr (nfloat v)
1940                 {
1941 #if NINT_JIT_OPTIMIZED
1942                         throw new NotImplementedException ();
1943 #elif ARCH_32
1944                         return *((IntPtr *)&v.v);
1945 #else
1946                         return *((IntPtr *)&v.v);
1947 #endif
1948                 }
1949
1950                 public static implicit operator nfloat (sbyte v)
1951                 {
1952 #if NINT_JIT_OPTIMIZED
1953                         throw new NotImplementedException ();
1954 #elif ARCH_32
1955                         return new nfloat ((float)v);
1956 #else
1957                         return new nfloat ((double)v);
1958 #endif
1959                 }
1960
1961                 public static explicit operator sbyte (nfloat v)
1962                 {
1963 #if NINT_JIT_OPTIMIZED
1964                         throw new NotImplementedException ();
1965 #elif ARCH_32
1966                         return (sbyte)v.v;
1967 #else
1968                         return (sbyte)v.v;
1969 #endif
1970                 }
1971
1972                 public static implicit operator nfloat (byte v)
1973                 {
1974 #if NINT_JIT_OPTIMIZED
1975                         throw new NotImplementedException ();
1976 #elif ARCH_32
1977                         return new nfloat ((float)v);
1978 #else
1979                         return new nfloat ((double)v);
1980 #endif
1981                 }
1982
1983                 public static explicit operator byte (nfloat v)
1984                 {
1985 #if NINT_JIT_OPTIMIZED
1986                         throw new NotImplementedException ();
1987 #elif ARCH_32
1988                         return (byte)v.v;
1989 #else
1990                         return (byte)v.v;
1991 #endif
1992                 }
1993
1994                 public static implicit operator nfloat (char v)
1995                 {
1996 #if NINT_JIT_OPTIMIZED
1997                         throw new NotImplementedException ();
1998 #elif ARCH_32
1999                         return new nfloat ((float)v);
2000 #else
2001                         return new nfloat ((double)v);
2002 #endif
2003                 }
2004
2005                 public static explicit operator char (nfloat v)
2006                 {
2007 #if NINT_JIT_OPTIMIZED
2008                         throw new NotImplementedException ();
2009 #elif ARCH_32
2010                         return (char)v.v;
2011 #else
2012                         return (char)v.v;
2013 #endif
2014                 }
2015
2016                 public static implicit operator nfloat (short v)
2017                 {
2018 #if NINT_JIT_OPTIMIZED
2019                         throw new NotImplementedException ();
2020 #elif ARCH_32
2021                         return new nfloat ((float)v);
2022 #else
2023                         return new nfloat ((double)v);
2024 #endif
2025                 }
2026
2027                 public static explicit operator short (nfloat v)
2028                 {
2029 #if NINT_JIT_OPTIMIZED
2030                         throw new NotImplementedException ();
2031 #elif ARCH_32
2032                         return (short)v.v;
2033 #else
2034                         return (short)v.v;
2035 #endif
2036                 }
2037
2038                 public static implicit operator nfloat (ushort v)
2039                 {
2040 #if NINT_JIT_OPTIMIZED
2041                         throw new NotImplementedException ();
2042 #elif ARCH_32
2043                         return new nfloat ((float)v);
2044 #else
2045                         return new nfloat ((double)v);
2046 #endif
2047                 }
2048
2049                 public static explicit operator ushort (nfloat v)
2050                 {
2051 #if NINT_JIT_OPTIMIZED
2052                         throw new NotImplementedException ();
2053 #elif ARCH_32
2054                         return (ushort)v.v;
2055 #else
2056                         return (ushort)v.v;
2057 #endif
2058                 }
2059
2060                 public static implicit operator nfloat (int v)
2061                 {
2062 #if NINT_JIT_OPTIMIZED
2063                         throw new NotImplementedException ();
2064 #elif ARCH_32
2065                         return new nfloat ((float)v);
2066 #else
2067                         return new nfloat ((double)v);
2068 #endif
2069                 }
2070
2071                 public static explicit operator int (nfloat v)
2072                 {
2073 #if NINT_JIT_OPTIMIZED
2074                         throw new NotImplementedException ();
2075 #elif ARCH_32
2076                         return (int)v.v;
2077 #else
2078                         return (int)v.v;
2079 #endif
2080                 }
2081
2082                 public static implicit operator nfloat (uint v)
2083                 {
2084 #if NINT_JIT_OPTIMIZED
2085                         throw new NotImplementedException ();
2086 #elif ARCH_32
2087                         return new nfloat ((float)v);
2088 #else
2089                         return new nfloat ((double)v);
2090 #endif
2091                 }
2092
2093                 public static explicit operator uint (nfloat v)
2094                 {
2095 #if NINT_JIT_OPTIMIZED
2096                         throw new NotImplementedException ();
2097 #elif ARCH_32
2098                         return (uint)v.v;
2099 #else
2100                         return (uint)v.v;
2101 #endif
2102                 }
2103
2104                 public static implicit operator nfloat (long v)
2105                 {
2106 #if NINT_JIT_OPTIMIZED
2107                         throw new NotImplementedException ();
2108 #elif ARCH_32
2109                         return new nfloat ((float)v);
2110 #else
2111                         return new nfloat ((double)v);
2112 #endif
2113                 }
2114
2115                 public static explicit operator long (nfloat v)
2116                 {
2117 #if NINT_JIT_OPTIMIZED
2118                         throw new NotImplementedException ();
2119 #elif ARCH_32
2120                         return (long)v.v;
2121 #else
2122                         return (long)v.v;
2123 #endif
2124                 }
2125
2126                 public static implicit operator nfloat (ulong v)
2127                 {
2128 #if NINT_JIT_OPTIMIZED
2129                         throw new NotImplementedException ();
2130 #elif ARCH_32
2131                         return new nfloat ((float)v);
2132 #else
2133                         return new nfloat ((double)v);
2134 #endif
2135                 }
2136
2137                 public static explicit operator ulong (nfloat v)
2138                 {
2139 #if NINT_JIT_OPTIMIZED
2140                         throw new NotImplementedException ();
2141 #elif ARCH_32
2142                         return (ulong)v.v;
2143 #else
2144                         return (ulong)v.v;
2145 #endif
2146                 }
2147
2148                 public static implicit operator nfloat (float v)
2149                 {
2150 #if NINT_JIT_OPTIMIZED
2151                         throw new NotImplementedException ();
2152 #elif ARCH_32
2153                         return new nfloat ((float)v);
2154 #else
2155                         return new nfloat ((double)v);
2156 #endif
2157                 }
2158
2159                 public static explicit operator float (nfloat v)
2160                 {
2161 #if NINT_JIT_OPTIMIZED
2162                         throw new NotImplementedException ();
2163 #elif ARCH_32
2164                         return (float)v.v;
2165 #else
2166                         return (float)v.v;
2167 #endif
2168                 }
2169
2170                 public static explicit operator nfloat (double v)
2171                 {
2172 #if NINT_JIT_OPTIMIZED
2173                         throw new NotImplementedException ();
2174 #elif ARCH_32
2175                         return new nfloat ((float)v);
2176 #else
2177                         return new nfloat ((double)v);
2178 #endif
2179                 }
2180
2181                 public static implicit operator double (nfloat v)
2182                 {
2183 #if NINT_JIT_OPTIMIZED
2184                         throw new NotImplementedException ();
2185 #elif ARCH_32
2186                         return (double)v.v;
2187 #else
2188                         return (double)v.v;
2189 #endif
2190                 }
2191
2192                 public static explicit operator nfloat (decimal v)
2193                 {
2194 #if NINT_JIT_OPTIMIZED
2195                         throw new NotImplementedException ();
2196 #elif ARCH_32
2197                         return new nfloat ((float)v);
2198 #else
2199                         return new nfloat ((double)v);
2200 #endif
2201                 }
2202
2203                 public static explicit operator decimal (nfloat v)
2204                 {
2205 #if NINT_JIT_OPTIMIZED
2206                         throw new NotImplementedException ();
2207 #elif ARCH_32
2208                         return (decimal)v.v;
2209 #else
2210                         return (decimal)v.v;
2211 #endif
2212                 }
2213
2214 #if NINT_JIT_OPTIMIZED
2215                 public static nfloat operator + (nfloat v) { throw new NotImplementedException (); }
2216                 public static nfloat operator - (nfloat v) { throw new NotImplementedException (); }
2217 #else
2218                 public static nfloat operator + (nfloat v) { return new nfloat (+v.v); }
2219                 public static nfloat operator - (nfloat v) { return new nfloat (-v.v); }
2220 #endif
2221
2222 #if NINT_JIT_OPTIMIZED
2223                 public static nfloat operator ++ (nfloat v) { throw new NotImplementedException (); }
2224                 public static nfloat operator -- (nfloat v) { throw new NotImplementedException (); }
2225 #else
2226                 public static nfloat operator ++ (nfloat v) { return new nfloat (v.v + 1); }
2227                 public static nfloat operator -- (nfloat v) { return new nfloat (v.v - 1); }
2228 #endif
2229
2230 #if NINT_JIT_OPTIMIZED
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                 public static nfloat operator / (nfloat l, nfloat r) { throw new NotImplementedException (); }
2235                 public static nfloat operator % (nfloat l, nfloat r) { throw new NotImplementedException (); }
2236 #else
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                 public static nfloat operator / (nfloat l, nfloat r) { return new nfloat (l.v / r.v); }
2241                 public static nfloat operator % (nfloat l, nfloat r) { return new nfloat (l.v % r.v); }
2242 #endif
2243
2244 #if NINT_JIT_OPTIMIZED
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                 public static bool operator <= (nfloat l, nfloat r) { throw new NotImplementedException (); }
2250                 public static bool operator >= (nfloat l, nfloat r) { throw new NotImplementedException (); }
2251 #else
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                 public static bool operator <= (nfloat l, nfloat r) { return l.v <= r.v; }
2257                 public static bool operator >= (nfloat l, nfloat r) { return l.v >= r.v; }
2258 #endif
2259
2260                 public int CompareTo (nfloat value) { return v.CompareTo (value.v); }
2261                 public int CompareTo (object value)
2262                 {
2263                         if (value is nfloat)
2264                                 return v.CompareTo (((nfloat) value).v);
2265                         return v.CompareTo (value);
2266                 }
2267                 public bool Equals (nfloat obj) { return v.Equals (obj.v); }
2268                 public override bool Equals (object obj)
2269                 {
2270                         if (obj is nfloat)
2271                                 return v.Equals (((nfloat) obj).v);
2272                         return v.Equals (obj);
2273                 }
2274                 public override int GetHashCode () { return v.GetHashCode (); }
2275
2276 #if ARCH_32
2277                 public static bool IsNaN              (nfloat f) { return Single.IsNaN ((Single)f); }
2278                 public static bool IsInfinity         (nfloat f) { return Single.IsInfinity ((Single)f); }
2279                 public static bool IsPositiveInfinity (nfloat f) { return Single.IsPositiveInfinity ((Single)f); }
2280                 public static bool IsNegativeInfinity (nfloat f) { return Single.IsNegativeInfinity ((Single)f); }
2281
2282                 public static nfloat Parse (string s, IFormatProvider provider) { return (nfloat)Single.Parse (s, provider); }
2283                 public static nfloat Parse (string s, NumberStyles style) { return (nfloat)Single.Parse (s, style); }
2284                 public static nfloat Parse (string s) { return (nfloat)Single.Parse (s); }
2285                 public static nfloat Parse (string s, NumberStyles style, IFormatProvider provider) {
2286                         return (nfloat)Single.Parse (s, style, provider);
2287                 }
2288
2289                 public static bool TryParse (string s, out nfloat result)
2290                 {
2291                         Single v;
2292                         var r = Single.TryParse (s, out v);
2293                         result = (nfloat)v;
2294                         return r;
2295                 }
2296
2297                 public static bool TryParse (string s, NumberStyles style, IFormatProvider provider, out nfloat result)
2298                 {
2299                         Single v;
2300                         var r = Single.TryParse (s, style, provider, out v);
2301                         result = (nfloat)v;
2302                         return r;
2303                 }
2304 #else
2305                 public static bool IsNaN              (nfloat f) { return Double.IsNaN ((Double)f); }
2306                 public static bool IsInfinity         (nfloat f) { return Double.IsInfinity ((Double)f); }
2307                 public static bool IsPositiveInfinity (nfloat f) { return Double.IsPositiveInfinity ((Double)f); }
2308                 public static bool IsNegativeInfinity (nfloat f) { return Double.IsNegativeInfinity ((Double)f); }
2309
2310                 public static nfloat Parse (string s, IFormatProvider provider) { return (nfloat)Double.Parse (s, provider); }
2311                 public static nfloat Parse (string s, NumberStyles style) { return (nfloat)Double.Parse (s, style); }
2312                 public static nfloat Parse (string s) { return (nfloat)Double.Parse (s); }
2313                 public static nfloat Parse (string s, NumberStyles style, IFormatProvider provider) {
2314                         return (nfloat)Double.Parse (s, style, provider);
2315                 }
2316
2317                 public static bool TryParse (string s, out nfloat result)
2318                 {
2319                         Double v;
2320                         var r = Double.TryParse (s, out v);
2321                         result = (nfloat)v;
2322                         return r;
2323                 }
2324
2325                 public static bool TryParse (string s, NumberStyles style, IFormatProvider provider, out nfloat result)
2326                 {
2327                         Double v;
2328                         var r = Double.TryParse (s, style, provider, out v);
2329                         result = (nfloat)v;
2330                         return r;
2331                 }
2332 #endif
2333
2334                 public override string ToString () { return v.ToString (); }
2335                 public string ToString (IFormatProvider provider) { return v.ToString (provider); }
2336                 public string ToString (string format) { return v.ToString (format); }
2337                 public string ToString (string format, IFormatProvider provider) { return v.ToString (format, provider); }
2338
2339                 public TypeCode GetTypeCode () { return v.GetTypeCode (); }
2340
2341                 bool     IConvertible.ToBoolean  (IFormatProvider provider) { return ((IConvertible)v).ToBoolean (provider); }
2342                 byte     IConvertible.ToByte     (IFormatProvider provider) { return ((IConvertible)v).ToByte (provider); }
2343                 char     IConvertible.ToChar     (IFormatProvider provider) { return ((IConvertible)v).ToChar (provider); }
2344                 DateTime IConvertible.ToDateTime (IFormatProvider provider) { return ((IConvertible)v).ToDateTime (provider); }
2345                 decimal  IConvertible.ToDecimal  (IFormatProvider provider) { return ((IConvertible)v).ToDecimal (provider); }
2346                 double   IConvertible.ToDouble   (IFormatProvider provider) { return ((IConvertible)v).ToDouble (provider); }
2347                 short    IConvertible.ToInt16    (IFormatProvider provider) { return ((IConvertible)v).ToInt16 (provider); }
2348                 int      IConvertible.ToInt32    (IFormatProvider provider) { return ((IConvertible)v).ToInt32 (provider); }
2349                 long     IConvertible.ToInt64    (IFormatProvider provider) { return ((IConvertible)v).ToInt64 (provider); }
2350                 sbyte    IConvertible.ToSByte    (IFormatProvider provider) { return ((IConvertible)v).ToSByte (provider); }
2351                 float    IConvertible.ToSingle   (IFormatProvider provider) { return ((IConvertible)v).ToSingle (provider); }
2352                 ushort   IConvertible.ToUInt16   (IFormatProvider provider) { return ((IConvertible)v).ToUInt16 (provider); }
2353                 uint     IConvertible.ToUInt32   (IFormatProvider provider) { return ((IConvertible)v).ToUInt32 (provider); }
2354                 ulong    IConvertible.ToUInt64   (IFormatProvider provider) { return ((IConvertible)v).ToUInt64 (provider); }
2355
2356                 object IConvertible.ToType (Type targetType, IFormatProvider provider) {
2357                         return ((IConvertible)v).ToType (targetType, provider);
2358                 }
2359
2360                 public static void CopyArray (IntPtr source, nfloat [] destination, int startIndex, int length)
2361                 {
2362                         if (source == IntPtr.Zero)
2363                                 throw new ArgumentNullException ("source");
2364                         if (destination == null)
2365                                 throw new ArgumentNullException ("destination");
2366                         if (destination.Rank != 1)
2367                                 throw new ArgumentException ("destination", "array is multi-dimensional");
2368                         if (startIndex < 0)
2369                                 throw new ArgumentException ("startIndex", "must be >= 0");
2370                         if (length < 0)
2371                                 throw new ArgumentException ("length", "must be >= 0");
2372                         if (startIndex + length > destination.Length)
2373                                 throw new ArgumentException ("length", "startIndex + length > destination.Length");
2374
2375                         for (int i = 0; i < length; i++)
2376                                 destination [i + startIndex] = (nfloat)Marshal.ReadIntPtr (source, i * nfloat.Size);
2377                 }
2378
2379                 public static void CopyArray (nfloat [] source, int startIndex, IntPtr destination, int length)
2380                 {
2381                         if (source == null)
2382                                 throw new ArgumentNullException ("source");
2383                         if (destination == IntPtr.Zero)
2384                                 throw new ArgumentNullException ("destination");
2385                         if (source.Rank != 1)
2386                                 throw new ArgumentException ("source", "array is multi-dimensional");
2387                         if (startIndex < 0)
2388                                 throw new ArgumentException ("startIndex", "must be >= 0");
2389                         if (length < 0)
2390                                 throw new ArgumentException ("length", "must be >= 0");
2391                         if (startIndex + length > source.Length)
2392                                 throw new ArgumentException ("length", "startIndex + length > source.Length");
2393
2394                         for (int i = 0; i < length; i++)
2395                                 Marshal.WriteIntPtr (destination, i * nfloat.Size, (IntPtr)source [i + startIndex]);
2396                 }
2397         }
2398 }