Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UInt64.cs
Go to the documentation of this file.
6
7namespace System;
8
10[CLSCompliant(false)]
11[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
12public readonly struct UInt64 : IComparable, IConvertible, ISpanFormattable, IFormattable, IComparable<ulong>, IEquatable<ulong>, IBinaryInteger<ulong>, IBinaryNumber<ulong>, IBitwiseOperators<ulong, ulong, ulong>, INumber<ulong>, IAdditionOperators<ulong, ulong, ulong>, IAdditiveIdentity<ulong, ulong>, IComparisonOperators<ulong, ulong>, IEqualityOperators<ulong, ulong>, IDecrementOperators<ulong>, IDivisionOperators<ulong, ulong, ulong>, IIncrementOperators<ulong>, IModulusOperators<ulong, ulong, ulong>, IMultiplicativeIdentity<ulong, ulong>, IMultiplyOperators<ulong, ulong, ulong>, ISpanParseable<ulong>, IParseable<ulong>, ISubtractionOperators<ulong, ulong, ulong>, IUnaryNegationOperators<ulong, ulong>, IUnaryPlusOperators<ulong, ulong>, IShiftOperators<ulong, ulong>, IMinMaxValue<ulong>, IUnsignedNumber<ulong>
13{
14 private readonly ulong m_value;
15
16 public const ulong MaxValue = 18446744073709551615uL;
17
18 public const ulong MinValue = 0uL;
19
20 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
22
23 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
24 static ulong IMinMaxValue<ulong>.MinValue => 0uL;
25
26 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
27 static ulong IMinMaxValue<ulong>.MaxValue => ulong.MaxValue;
28
29 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
31
32 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
33 static ulong INumber<ulong>.One => 1uL;
34
35 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
36 static ulong INumber<ulong>.Zero => 0uL;
37
38 public int CompareTo(object? value)
39 {
40 if (value == null)
41 {
42 return 1;
43 }
44 if (value is ulong num)
45 {
46 if (this < num)
47 {
48 return -1;
49 }
50 if (this > num)
51 {
52 return 1;
53 }
54 return 0;
55 }
57 }
58
59 public int CompareTo(ulong value)
60 {
61 if (this < value)
62 {
63 return -1;
64 }
65 if (this > value)
66 {
67 return 1;
68 }
69 return 0;
70 }
71
72 public override bool Equals([NotNullWhen(true)] object? obj)
73 {
74 if (!(obj is ulong))
75 {
76 return false;
77 }
78 return this == (ulong)obj;
79 }
80
81 [NonVersionable]
82 public bool Equals(ulong obj)
83 {
84 return this == obj;
85 }
86
87 public override int GetHashCode()
88 {
89 return (int)this ^ (int)(this >> 32);
90 }
91
92 public override string ToString()
93 {
94 return Number.UInt64ToDecStr(this, -1);
95 }
96
97 public string ToString(IFormatProvider? provider)
98 {
99 return Number.UInt64ToDecStr(this, -1);
100 }
101
102 public string ToString(string? format)
103 {
104 return Number.FormatUInt64(this, format, null);
105 }
106
107 public string ToString(string? format, IFormatProvider? provider)
108 {
109 return Number.FormatUInt64(this, format, provider);
110 }
111
112 public bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default(ReadOnlySpan<char>), IFormatProvider? provider = null)
113 {
114 return Number.TryFormatUInt64(this, format, provider, destination, out charsWritten);
115 }
116
117 public static ulong Parse(string s)
118 {
119 if (s == null)
120 {
122 }
124 }
125
126 public static ulong Parse(string s, NumberStyles style)
127 {
129 if (s == null)
130 {
132 }
134 }
135
136 public static ulong Parse(string s, IFormatProvider? provider)
137 {
138 if (s == null)
139 {
141 }
142 return Number.ParseUInt64(s, NumberStyles.Integer, NumberFormatInfo.GetInstance(provider));
143 }
144
145 public static ulong Parse(string s, NumberStyles style, IFormatProvider? provider)
146 {
148 if (s == null)
149 {
151 }
152 return Number.ParseUInt64(s, style, NumberFormatInfo.GetInstance(provider));
153 }
154
155 public static ulong Parse(ReadOnlySpan<char> s, NumberStyles style = NumberStyles.Integer, IFormatProvider? provider = null)
156 {
158 return Number.ParseUInt64(s, style, NumberFormatInfo.GetInstance(provider));
159 }
160
161 public static bool TryParse([NotNullWhen(true)] string? s, out ulong result)
162 {
163 if (s == null)
164 {
165 result = 0uL;
166 return false;
167 }
169 }
170
171 public static bool TryParse(ReadOnlySpan<char> s, out ulong result)
172 {
174 }
175
176 public static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out ulong result)
177 {
179 if (s == null)
180 {
181 result = 0uL;
182 return false;
183 }
184 return Number.TryParseUInt64(s, style, NumberFormatInfo.GetInstance(provider), out result) == Number.ParsingStatus.OK;
185 }
186
187 public static bool TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider? provider, out ulong result)
188 {
190 return Number.TryParseUInt64(s, style, NumberFormatInfo.GetInstance(provider), out result) == Number.ParsingStatus.OK;
191 }
192
194 {
195 return TypeCode.UInt64;
196 }
197
199 {
200 return Convert.ToBoolean(this);
201 }
202
204 {
205 return Convert.ToChar(this);
206 }
207
209 {
210 return Convert.ToSByte(this);
211 }
212
214 {
215 return Convert.ToByte(this);
216 }
217
219 {
220 return Convert.ToInt16(this);
221 }
222
224 {
225 return Convert.ToUInt16(this);
226 }
227
229 {
230 return Convert.ToInt32(this);
231 }
232
234 {
235 return Convert.ToUInt32(this);
236 }
237
239 {
240 return Convert.ToInt64(this);
241 }
242
244 {
245 return this;
246 }
247
249 {
250 return Convert.ToSingle(this);
251 }
252
254 {
255 return Convert.ToDouble(this);
256 }
257
259 {
260 return Convert.ToDecimal(this);
261 }
262
264 {
265 throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "UInt64", "DateTime"));
266 }
267
269 {
270 return Convert.DefaultToType(this, type, provider);
271 }
272
273 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
274 static ulong IAdditionOperators<ulong, ulong, ulong>.operator +(ulong left, ulong right)
275 {
276 return left + right;
277 }
278
279 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
281 {
282 return (ulong)BitOperations.LeadingZeroCount(value);
283 }
284
285 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
287 {
288 return (ulong)BitOperations.PopCount(value);
289 }
290
291 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
292 static ulong IBinaryInteger<ulong>.RotateLeft(ulong value, int rotateAmount)
293 {
294 return BitOperations.RotateLeft(value, rotateAmount);
295 }
296
297 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
298 static ulong IBinaryInteger<ulong>.RotateRight(ulong value, int rotateAmount)
299 {
300 return BitOperations.RotateRight(value, rotateAmount);
301 }
302
303 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
305 {
307 }
308
309 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
311 {
312 return BitOperations.IsPow2(value);
313 }
314
315 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
316 static ulong IBinaryNumber<ulong>.Log2(ulong value)
317 {
318 return (ulong)BitOperations.Log2(value);
319 }
320
321 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
322 static ulong IBitwiseOperators<ulong, ulong, ulong>.operator &(ulong left, ulong right)
323 {
324 return left & right;
325 }
326
327 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
328 static ulong IBitwiseOperators<ulong, ulong, ulong>.operator |(ulong left, ulong right)
329 {
330 return left | right;
331 }
332
333 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
334 static ulong IBitwiseOperators<ulong, ulong, ulong>.operator ^(ulong left, ulong right)
335 {
336 return left ^ right;
337 }
338
339 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
340 static ulong IBitwiseOperators<ulong, ulong, ulong>.operator ~(ulong value)
341 {
342 return ~value;
343 }
344
345 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
346 static bool IComparisonOperators<ulong, ulong>.operator <(ulong left, ulong right)
347 {
348 return left < right;
349 }
350
351 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
352 static bool IComparisonOperators<ulong, ulong>.operator <=(ulong left, ulong right)
353 {
354 return left <= right;
355 }
356
357 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
358 static bool IComparisonOperators<ulong, ulong>.operator >(ulong left, ulong right)
359 {
360 return left > right;
361 }
362
363 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
364 static bool IComparisonOperators<ulong, ulong>.operator >=(ulong left, ulong right)
365 {
366 return left >= right;
367 }
368
369 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
370 static ulong IDecrementOperators<ulong>.operator --(ulong value)
371 {
372 return --value;
373 }
374
375 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
376 static ulong IDivisionOperators<ulong, ulong, ulong>.operator /(ulong left, ulong right)
377 {
378 return left / right;
379 }
380
381 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
382 static bool IEqualityOperators<ulong, ulong>.operator ==(ulong left, ulong right)
383 {
384 return left == right;
385 }
386
387 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
388 static bool IEqualityOperators<ulong, ulong>.operator !=(ulong left, ulong right)
389 {
390 return left != right;
391 }
392
393 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
394 static ulong IIncrementOperators<ulong>.operator ++(ulong value)
395 {
396 return ++value;
397 }
398
399 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
400 static ulong IModulusOperators<ulong, ulong, ulong>.operator %(ulong left, ulong right)
401 {
402 return left % right;
403 }
404
405 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
406 static ulong IMultiplyOperators<ulong, ulong, ulong>.operator *(ulong left, ulong right)
407 {
408 return left * right;
409 }
410
411 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
412 static ulong INumber<ulong>.Abs(ulong value)
413 {
414 return value;
415 }
416
417 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
418 static ulong INumber<ulong>.Clamp(ulong value, ulong min, ulong max)
419 {
420 return Math.Clamp(value, min, max);
421 }
422
423 [MethodImpl(MethodImplOptions.AggressiveInlining)]
424 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
425 static ulong INumber<ulong>.Create<TOther>(TOther value)
426 {
427 if (typeof(TOther) == typeof(byte))
428 {
429 return (byte)(object)value;
430 }
431 if (typeof(TOther) == typeof(char))
432 {
433 return (char)(object)value;
434 }
435 if (typeof(TOther) == typeof(decimal))
436 {
437 return (ulong)(decimal)(object)value;
438 }
439 checked
440 {
441 if (typeof(TOther) == typeof(double))
442 {
443 return (ulong)(double)(object)value;
444 }
445 if (typeof(TOther) == typeof(short))
446 {
447 return (ulong)(short)(object)value;
448 }
449 if (typeof(TOther) == typeof(int))
450 {
451 return (ulong)(int)(object)value;
452 }
453 if (typeof(TOther) == typeof(long))
454 {
455 return (ulong)(long)(object)value;
456 }
457 if (typeof(TOther) == typeof(IntPtr))
458 {
459 return (ulong)(nint)(IntPtr)(object)value;
460 }
461 if (typeof(TOther) == typeof(sbyte))
462 {
463 return (ulong)(sbyte)(object)value;
464 }
465 if (typeof(TOther) == typeof(float))
466 {
467 return (ulong)(float)(object)value;
468 }
469 if (typeof(TOther) == typeof(ushort))
470 {
471 return (ushort)(object)value;
472 }
473 if (typeof(TOther) == typeof(uint))
474 {
475 return (uint)(object)value;
476 }
477 if (typeof(TOther) == typeof(ulong))
478 {
479 return (ulong)(object)value;
480 }
481 }
482 if (typeof(TOther) == typeof(UIntPtr))
483 {
484 return (ulong)(UIntPtr)(object)value;
485 }
487 return 0uL;
488 }
489
490 [MethodImpl(MethodImplOptions.AggressiveInlining)]
491 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
492 static ulong INumber<ulong>.CreateSaturating<TOther>(TOther value)
493 {
494 if (typeof(TOther) == typeof(byte))
495 {
496 return (byte)(object)value;
497 }
498 if (typeof(TOther) == typeof(char))
499 {
500 return (char)(object)value;
501 }
502 if (typeof(TOther) == typeof(decimal))
503 {
504 decimal num = (decimal)(object)value;
505 if (!(num > 18446744073709551615m))
506 {
507 if (!(num < 0m))
508 {
509 return (ulong)num;
510 }
511 return 0uL;
512 }
513 return ulong.MaxValue;
514 }
515 if (typeof(TOther) == typeof(double))
516 {
517 double num2 = (double)(object)value;
518 if (!(num2 > 1.8446744073709552E+19))
519 {
520 if (!(num2 < 0.0))
521 {
522 return (ulong)num2;
523 }
524 return 0uL;
525 }
526 return ulong.MaxValue;
527 }
528 if (typeof(TOther) == typeof(short))
529 {
530 short num3 = (short)(object)value;
531 if (num3 >= 0)
532 {
533 return (ulong)num3;
534 }
535 return 0uL;
536 }
537 if (typeof(TOther) == typeof(int))
538 {
539 int num4 = (int)(object)value;
540 if (num4 >= 0)
541 {
542 return (ulong)num4;
543 }
544 return 0uL;
545 }
546 if (typeof(TOther) == typeof(long))
547 {
548 long num5 = (long)(object)value;
549 if (num5 >= 0)
550 {
551 return (ulong)num5;
552 }
553 return 0uL;
554 }
555 if (typeof(TOther) == typeof(IntPtr))
556 {
557 IntPtr intPtr = (IntPtr)(object)value;
558 if ((nint)intPtr >= 0)
559 {
560 return (ulong)(nint)intPtr;
561 }
562 return 0uL;
563 }
564 if (typeof(TOther) == typeof(sbyte))
565 {
566 sbyte b = (sbyte)(object)value;
567 if (b >= 0)
568 {
569 return (ulong)b;
570 }
571 return 0uL;
572 }
573 if (typeof(TOther) == typeof(float))
574 {
575 float num6 = (float)(object)value;
576 if (!(num6 > 1.8446744E+19f))
577 {
578 if (!(num6 < 0f))
579 {
580 return (ulong)num6;
581 }
582 return 0uL;
583 }
584 return ulong.MaxValue;
585 }
586 if (typeof(TOther) == typeof(ushort))
587 {
588 return (ushort)(object)value;
589 }
590 if (typeof(TOther) == typeof(uint))
591 {
592 return (uint)(object)value;
593 }
594 if (typeof(TOther) == typeof(ulong))
595 {
596 return (ulong)(object)value;
597 }
598 if (typeof(TOther) == typeof(UIntPtr))
599 {
600 return (ulong)(UIntPtr)(object)value;
601 }
603 return 0uL;
604 }
605
606 [MethodImpl(MethodImplOptions.AggressiveInlining)]
607 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
608 static ulong INumber<ulong>.CreateTruncating<TOther>(TOther value)
609 {
610 if (typeof(TOther) == typeof(byte))
611 {
612 return (byte)(object)value;
613 }
614 if (typeof(TOther) == typeof(char))
615 {
616 return (char)(object)value;
617 }
618 if (typeof(TOther) == typeof(decimal))
619 {
620 return (ulong)(decimal)(object)value;
621 }
622 if (typeof(TOther) == typeof(double))
623 {
624 return (ulong)(double)(object)value;
625 }
626 if (typeof(TOther) == typeof(short))
627 {
628 return (ulong)(short)(object)value;
629 }
630 if (typeof(TOther) == typeof(int))
631 {
632 return (ulong)(int)(object)value;
633 }
634 if (typeof(TOther) == typeof(long))
635 {
636 return (ulong)(long)(object)value;
637 }
638 if (typeof(TOther) == typeof(IntPtr))
639 {
640 return (ulong)(nint)(IntPtr)(object)value;
641 }
642 if (typeof(TOther) == typeof(sbyte))
643 {
644 return (ulong)(sbyte)(object)value;
645 }
646 if (typeof(TOther) == typeof(float))
647 {
648 return (ulong)(float)(object)value;
649 }
650 if (typeof(TOther) == typeof(ushort))
651 {
652 return (ushort)(object)value;
653 }
654 if (typeof(TOther) == typeof(uint))
655 {
656 return (uint)(object)value;
657 }
658 if (typeof(TOther) == typeof(ulong))
659 {
660 return (ulong)(object)value;
661 }
662 if (typeof(TOther) == typeof(UIntPtr))
663 {
664 return (ulong)(UIntPtr)(object)value;
665 }
667 return 0uL;
668 }
669
670 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
671 static (ulong Quotient, ulong Remainder) INumber<ulong>.DivRem(ulong left, ulong right)
672 {
673 return Math.DivRem(left, right);
674 }
675
676 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
677 static ulong INumber<ulong>.Max(ulong x, ulong y)
678 {
679 return Math.Max(x, y);
680 }
681
682 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
683 static ulong INumber<ulong>.Min(ulong x, ulong y)
684 {
685 return Math.Min(x, y);
686 }
687
688 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
689 static ulong INumber<ulong>.Parse(string s, NumberStyles style, IFormatProvider provider)
690 {
691 return Parse(s, style, provider);
692 }
693
694 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
696 {
697 return Parse(s, style, provider);
698 }
699
700 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
701 static ulong INumber<ulong>.Sign(ulong value)
702 {
703 return (ulong)((value != 0L) ? 1 : 0);
704 }
705
706 [MethodImpl(MethodImplOptions.AggressiveInlining)]
707 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
708 static bool INumber<ulong>.TryCreate<TOther>(TOther value, out ulong result)
709 {
710 if (typeof(TOther) == typeof(byte))
711 {
712 result = (byte)(object)value;
713 return true;
714 }
715 if (typeof(TOther) == typeof(char))
716 {
717 result = (char)(object)value;
718 return true;
719 }
720 if (typeof(TOther) == typeof(decimal))
721 {
722 decimal num = (decimal)(object)value;
723 if (num < 0m || num > 18446744073709551615m)
724 {
725 result = 0uL;
726 return false;
727 }
728 result = (ulong)num;
729 return true;
730 }
731 if (typeof(TOther) == typeof(double))
732 {
733 double num2 = (double)(object)value;
734 if (num2 < 0.0 || num2 > 1.8446744073709552E+19)
735 {
736 result = 0uL;
737 return false;
738 }
739 result = (ulong)num2;
740 return true;
741 }
742 if (typeof(TOther) == typeof(short))
743 {
744 short num3 = (short)(object)value;
745 if (num3 < 0)
746 {
747 result = 0uL;
748 return false;
749 }
750 result = (ulong)num3;
751 return true;
752 }
753 if (typeof(TOther) == typeof(int))
754 {
755 int num4 = (int)(object)value;
756 if (num4 < 0)
757 {
758 result = 0uL;
759 return false;
760 }
761 result = (ulong)num4;
762 return true;
763 }
764 if (typeof(TOther) == typeof(long))
765 {
766 long num5 = (long)(object)value;
767 if (num5 < 0)
768 {
769 result = 0uL;
770 return false;
771 }
772 result = (ulong)num5;
773 return true;
774 }
775 if (typeof(TOther) == typeof(IntPtr))
776 {
777 IntPtr intPtr = (IntPtr)(object)value;
778 if ((nint)intPtr < 0)
779 {
780 result = 0uL;
781 return false;
782 }
783 result = (ulong)(nint)intPtr;
784 return true;
785 }
786 if (typeof(TOther) == typeof(sbyte))
787 {
788 sbyte b = (sbyte)(object)value;
789 if (b < 0)
790 {
791 result = 0uL;
792 return false;
793 }
794 result = (ulong)b;
795 return true;
796 }
797 if (typeof(TOther) == typeof(float))
798 {
799 float num6 = (float)(object)value;
800 if (num6 < 0f || num6 > 1.8446744E+19f)
801 {
802 result = 0uL;
803 return false;
804 }
805 result = (ulong)num6;
806 return true;
807 }
808 if (typeof(TOther) == typeof(ushort))
809 {
810 result = (ushort)(object)value;
811 return true;
812 }
813 if (typeof(TOther) == typeof(uint))
814 {
815 result = (uint)(object)value;
816 return true;
817 }
818 if (typeof(TOther) == typeof(ulong))
819 {
820 result = (ulong)(object)value;
821 return true;
822 }
823 if (typeof(TOther) == typeof(UIntPtr))
824 {
825 result = (ulong)(UIntPtr)(object)value;
826 return true;
827 }
829 result = 0uL;
830 return false;
831 }
832
833 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
834 static bool INumber<ulong>.TryParse([NotNullWhen(true)] string s, NumberStyles style, IFormatProvider provider, out ulong result)
835 {
836 return TryParse(s, style, provider, out result);
837 }
838
839 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
840 static bool INumber<ulong>.TryParse(ReadOnlySpan<char> s, NumberStyles style, IFormatProvider provider, out ulong result)
841 {
842 return TryParse(s, style, provider, out result);
843 }
844
845 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
846 static ulong IParseable<ulong>.Parse(string s, IFormatProvider provider)
847 {
848 return Parse(s, provider);
849 }
850
851 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
852 static bool IParseable<ulong>.TryParse([NotNullWhen(true)] string s, IFormatProvider provider, out ulong result)
853 {
854 return TryParse(s, NumberStyles.Integer, provider, out result);
855 }
856
857 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
858 static ulong IShiftOperators<ulong, ulong>.operator <<(ulong value, int shiftAmount)
859 {
860 return value << shiftAmount;
861 }
862
863 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
864 static ulong IShiftOperators<ulong, ulong>.operator >>(ulong value, int shiftAmount)
865 {
866 return value >> shiftAmount;
867 }
868
869 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
871 {
872 return Parse(s, NumberStyles.Integer, provider);
873 }
874
875 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
876 static bool ISpanParseable<ulong>.TryParse(ReadOnlySpan<char> s, IFormatProvider provider, out ulong result)
877 {
878 return TryParse(s, NumberStyles.Integer, provider, out result);
879 }
880
881 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
882 static ulong ISubtractionOperators<ulong, ulong, ulong>.operator -(ulong left, ulong right)
883 {
884 return left - right;
885 }
886
887 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
888 static ulong IUnaryNegationOperators<ulong, ulong>.operator -(ulong value)
889 {
890 return 0 - value;
891 }
892
893 [RequiresPreviewFeatures("Generic Math is in preview.", Url = "https://aka.ms/dotnet-warnings/generic-math-preview")]
894 static ulong IUnaryPlusOperators<ulong, ulong>.operator +(ulong value)
895 {
896 return value;
897 }
898}
static decimal ToDecimal(object? value)
Definition Convert.cs:2101
static long ToInt64(object? value)
Definition Convert.cs:1623
static float ToSingle(object? value)
Definition Convert.cs:1881
static int ToInt32(object? value)
Definition Convert.cs:1320
static short ToInt16(object? value)
Definition Convert.cs:1038
static byte ToByte(object? value)
Definition Convert.cs:900
static uint ToUInt32(object? value)
Definition Convert.cs:1470
static char ToChar(object? value)
Definition Convert.cs:618
static ushort ToUInt16(object? value)
Definition Convert.cs:1177
static sbyte ToSByte(object? value)
Definition Convert.cs:745
static double ToDouble(object? value)
Definition Convert.cs:1991
static bool ToBoolean([NotNullWhen(true)] object? value)
Definition Convert.cs:508
static object DefaultToType(IConvertible value, Type targetType, IFormatProvider provider)
Definition Convert.cs:269
static void ValidateParseStyleInteger(NumberStyles style)
static NumberFormatInfo GetInstance(IFormatProvider? formatProvider)
static byte Clamp(byte value, byte min, byte max)
Definition Math.cs:435
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static int DivRem(int a, int b, out int result)
Definition Math.cs:329
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static unsafe string UInt64ToDecStr(ulong value, int digits)
Definition Number.cs:2606
static bool TryFormatUInt64(ulong value, ReadOnlySpan< char > format, IFormatProvider provider, Span< char > destination, out int charsWritten)
Definition Number.cs:2184
static ParsingStatus TryParseUInt64(ReadOnlySpan< char > value, NumberStyles styles, NumberFormatInfo info, out ulong result)
Definition Number.cs:5119
static ParsingStatus TryParseUInt64IntegerStyle(ReadOnlySpan< char > value, NumberStyles styles, NumberFormatInfo info, out ulong result)
Definition Number.cs:5148
static ulong ParseUInt64(ReadOnlySpan< char > value, NumberStyles styles, NumberFormatInfo info)
Definition Number.cs:4030
static string FormatUInt64(ulong value, string format, IFormatProvider provider)
Definition Number.cs:2145
static int TrailingZeroCount(int value)
static bool IsPow2(int value)
static int PopCount(uint value)
static int Log2(uint value)
static uint RotateRight(uint value, int offset)
static int LeadingZeroCount(uint value)
static uint RotateLeft(uint value, int offset)
static string Arg_MustBeUInt64
Definition SR.cs:310
static string InvalidCast_FromTo
Definition SR.cs:1392
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
Definition SR.cs:7
static void ThrowNotSupportedException(ExceptionResource resource)
static void ThrowArgumentNullException(string name)
static TResult AdditiveIdentity
static TSelf RotateRight(TSelf value, int rotateAmount)
static TSelf LeadingZeroCount(TSelf value)
static TSelf PopCount(TSelf value)
static TSelf TrailingZeroCount(TSelf value)
static TSelf RotateLeft(TSelf value, int rotateAmount)
static bool IsPow2(TSelf value)
static TSelf Log2(TSelf value)
short ToInt16(IFormatProvider? provider)
char ToChar(IFormatProvider? provider)
byte ToByte(IFormatProvider? provider)
decimal ToDecimal(IFormatProvider? provider)
object ToType(Type conversionType, IFormatProvider? provider)
uint ToUInt32(IFormatProvider? provider)
DateTime ToDateTime(IFormatProvider? provider)
int ToInt32(IFormatProvider? provider)
long ToInt64(IFormatProvider? provider)
ushort ToUInt16(IFormatProvider? provider)
double ToDouble(IFormatProvider? provider)
float ToSingle(IFormatProvider? provider)
sbyte ToSByte(IFormatProvider? provider)
ulong ToUInt64(IFormatProvider? provider)
bool ToBoolean(IFormatProvider? provider)
static TSelf MinValue
static TSelf MaxValue
static TSelf Max(TSelf x, TSelf y)
static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out TSelf result)
static TSelf Parse(string s, NumberStyles style, IFormatProvider? provider)
static TSelf Sign(TSelf value)
static TSelf Min(TSelf x, TSelf y)
static TSelf One
Definition INumber.cs:10
static TSelf Zero
Definition INumber.cs:12
static TSelf Abs(TSelf value)
static TSelf Clamp(TSelf value, TSelf min, TSelf max)
static bool TryParse([NotNullWhen(true)] string? s, IFormatProvider? provider, out TSelf result)
static TSelf Parse(string s, IFormatProvider? provider)
static bool TryParse(ReadOnlySpan< char > s, IFormatProvider? provider, out TSelf result)
static TSelf Parse(ReadOnlySpan< char > s, IFormatProvider? provider)
TypeCode
Definition TypeCode.cs:4
override bool Equals([NotNullWhen(true)] object? obj)
Definition UInt64.cs:72
const ulong MinValue
Definition UInt64.cs:18
static ulong Parse(string s, IFormatProvider? provider)
Definition UInt64.cs:136
const ulong MaxValue
Definition UInt64.cs:16
static ulong ulong Remainder INumber< ulong >. DivRem(ulong left, ulong right)
Definition UInt64.cs:671
static bool TryParse(ReadOnlySpan< char > s, out ulong result)
Definition UInt64.cs:171
static bool TryParse([NotNullWhen(true)] string? s, NumberStyles style, IFormatProvider? provider, out ulong result)
Definition UInt64.cs:176
static bool TryParse(ReadOnlySpan< char > s, NumberStyles style, IFormatProvider? provider, out ulong result)
Definition UInt64.cs:187
string ToString(IFormatProvider? provider)
Definition UInt64.cs:97
string ToString(string? format, IFormatProvider? provider)
Definition UInt64.cs:107
static ulong Parse(string s)
Definition UInt64.cs:117
bool Equals(ulong obj)
Definition UInt64.cs:82
readonly ulong m_value
Definition UInt64.cs:14
static bool TryParse([NotNullWhen(true)] string? s, out ulong result)
Definition UInt64.cs:161
static ulong Parse(string s, NumberStyles style, IFormatProvider? provider)
Definition UInt64.cs:145
TypeCode GetTypeCode()
Definition UInt64.cs:193
static ulong Parse(ReadOnlySpan< char > s, NumberStyles style=NumberStyles.Integer, IFormatProvider? provider=null)
Definition UInt64.cs:155
override string ToString()
Definition UInt64.cs:92
int CompareTo(object? value)
Definition UInt64.cs:38
static ulong Quotient
Definition UInt64.cs:671
override int GetHashCode()
Definition UInt64.cs:87
string ToString(string? format)
Definition UInt64.cs:102
bool TryFormat(Span< char > destination, out int charsWritten, ReadOnlySpan< char > format=default(ReadOnlySpan< char >), IFormatProvider? provider=null)
Definition UInt64.cs:112
static ulong Parse(string s, NumberStyles style)
Definition UInt64.cs:126
int CompareTo(ulong value)
Definition UInt64.cs:59