Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CreateSaturating< TOther >()

static ulong INumber< ulong >. System.UInt64.CreateSaturating< TOther > ( TOther value)
inlinestatic

Definition at line 492 of file UInt64.cs.

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 }
602 ThrowHelper.ThrowNotSupportedException();
603 return 0uL;
604 }

References System.E, System.ThrowHelper.ThrowNotSupportedException(), and System.value.