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

◆ BigInteger() [12/12]

System.Numerics.BigInteger.BigInteger ( uint[] value)
inlineprivate

Definition at line 497 of file BigInteger.cs.

498 {
499 if (value == null)
500 {
501 throw new ArgumentNullException("value");
502 }
503 int num = value.Length;
504 bool flag = num > 0 && (value[num - 1] & 0x80000000u) == 2147483648u;
505 while (num > 0 && value[num - 1] == 0)
506 {
507 num--;
508 }
509 switch (num)
510 {
511 case 0:
512 this = s_bnZeroInt;
513 return;
514 case 1:
515 if ((int)value[0] < 0 && !flag)
516 {
517 _bits = new uint[1];
518 _bits[0] = value[0];
519 _sign = 1;
520 }
521 else if (int.MinValue == (int)value[0])
522 {
523 this = s_bnMinInt;
524 }
525 else
526 {
527 _sign = (int)value[0];
528 _bits = null;
529 }
530 return;
531 }
532 if (!flag)
533 {
534 if (num != value.Length)
535 {
536 _sign = 1;
537 _bits = new uint[num];
538 Array.Copy(value, _bits, num);
539 }
540 else
541 {
542 _sign = 1;
543 _bits = value;
544 }
545 return;
546 }
547 NumericsHelpers.DangerousMakeTwosComplement(value);
548 int num2 = value.Length;
549 while (num2 > 0 && value[num2 - 1] == 0)
550 {
551 num2--;
552 }
553 if (num2 == 1 && (int)value[0] > 0)
554 {
555 if (value[0] == 1)
556 {
557 this = s_bnMinusOneInt;
558 return;
559 }
560 if (value[0] == 2147483648u)
561 {
562 this = s_bnMinInt;
563 return;
564 }
565 _sign = -1 * (int)value[0];
566 _bits = null;
567 }
568 else if (num2 != value.Length)
569 {
570 _sign = -1;
571 _bits = new uint[num2];
572 Array.Copy(value, _bits, num2);
573 }
574 else
575 {
576 _sign = -1;
577 _bits = value;
578 }
579 }
static readonly BigInteger s_bnMinusOneInt
Definition BigInteger.cs:28
readonly uint[] _bits
Definition BigInteger.cs:20
static readonly BigInteger s_bnZeroInt
Definition BigInteger.cs:26
static readonly BigInteger s_bnMinInt
Definition BigInteger.cs:22

References System.Numerics.BigInteger._bits, System.Numerics.BigInteger._sign, System.Array.Copy(), System.Numerics.NumericsHelpers.DangerousMakeTwosComplement(), System.Numerics.BigInteger.s_bnMinInt, System.Numerics.BigInteger.s_bnMinusOneInt, System.Numerics.BigInteger.s_bnZeroInt, and System.value.