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

◆ CreateSaturating< TOther >()

static long INumber< long >. System.Int64.CreateSaturating< TOther > ( TOther value)
inlinestatic

Definition at line 498 of file Int64.cs.

499 {
500 if (typeof(TOther) == typeof(byte))
501 {
502 return (byte)(object)value;
503 }
504 if (typeof(TOther) == typeof(char))
505 {
506 return (char)(object)value;
507 }
508 if (typeof(TOther) == typeof(decimal))
509 {
510 decimal num = (decimal)(object)value;
511 if (!(num > 9223372036854775807m))
512 {
513 if (!(num < -9223372036854775808m))
514 {
515 return (long)num;
516 }
517 return long.MinValue;
518 }
519 return long.MaxValue;
520 }
521 if (typeof(TOther) == typeof(double))
522 {
523 double num2 = (double)(object)value;
524 if (!(num2 > 9.223372036854776E+18))
525 {
526 if (!(num2 < -9.223372036854776E+18))
527 {
528 return (long)num2;
529 }
530 return long.MinValue;
531 }
532 return long.MaxValue;
533 }
534 if (typeof(TOther) == typeof(short))
535 {
536 return (short)(object)value;
537 }
538 if (typeof(TOther) == typeof(int))
539 {
540 return (int)(object)value;
541 }
542 if (typeof(TOther) == typeof(long))
543 {
544 return (long)(object)value;
545 }
546 if (typeof(TOther) == typeof(IntPtr))
547 {
548 return (long)(IntPtr)(object)value;
549 }
550 if (typeof(TOther) == typeof(sbyte))
551 {
552 return (sbyte)(object)value;
553 }
554 if (typeof(TOther) == typeof(float))
555 {
556 float num3 = (float)(object)value;
557 if (!(num3 > 9.223372E+18f))
558 {
559 if (!(num3 < -9.223372E+18f))
560 {
561 return (long)num3;
562 }
563 return long.MinValue;
564 }
565 return long.MaxValue;
566 }
567 if (typeof(TOther) == typeof(ushort))
568 {
569 return (ushort)(object)value;
570 }
571 if (typeof(TOther) == typeof(uint))
572 {
573 return (uint)(object)value;
574 }
575 if (typeof(TOther) == typeof(ulong))
576 {
577 ulong num4 = (ulong)(object)value;
578 if (num4 <= long.MaxValue)
579 {
580 return (long)num4;
581 }
582 return long.MaxValue;
583 }
584 if (typeof(TOther) == typeof(UIntPtr))
585 {
586 UIntPtr uIntPtr = (UIntPtr)(object)value;
587 if ((ulong)(nuint)uIntPtr <= 9223372036854775807uL)
588 {
589 return (long)(nuint)uIntPtr;
590 }
591 return long.MaxValue;
592 }
593 ThrowHelper.ThrowNotSupportedException();
594 return 0L;
595 }
const long MaxValue
Definition Int64.cs:15

References System.E, System.L, System.Int64.MaxValue, System.UIntPtr.MaxValue, System.ThrowHelper.ThrowNotSupportedException(), and System.value.