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

◆ AdjustDbl()

double System.Xml.Xsl.XPathConvert.FloatingDecimal.AdjustDbl ( double dbl)
inlineprivate

Definition at line 1459 of file XPathConvert.cs.

1460 {
1463 bigInteger.InitFromFloatingDecimal(this);
1464 int num = _exponent - _mantissaSize;
1465 int num3;
1466 int num5;
1467 int num4;
1468 int num2;
1469 if (num >= 0)
1470 {
1471 num3 = (num2 = num);
1472 num5 = (num4 = 0);
1473 }
1474 else
1475 {
1476 num3 = (num2 = 0);
1477 num5 = (num4 = -num);
1478 }
1479 uint num6 = DblHi(dbl);
1480 uint num7 = DblLo(dbl);
1481 int num8 = (int)((num6 >> 20) & 0x7FF);
1482 num6 &= 0xFFFFFu;
1483 uint u = 1u;
1484 if (num8 != 0)
1485 {
1486 if (num6 == 0 && num7 == 0 && 1 != num8)
1487 {
1488 u = 2u;
1489 num6 = 2097152u;
1490 num8--;
1491 }
1492 else
1493 {
1494 num6 |= 0x100000u;
1495 }
1496 num8 -= 1076;
1497 }
1498 else
1499 {
1500 num8 = -1075;
1501 }
1502 num6 = (num6 << 1) | (num7 >> 31);
1503 num7 <<= 1;
1504 int cu = ((num7 != 0 || num6 != 0) ? ((num6 == 0) ? 1 : 2) : 0);
1505 bigInteger2.InitFromDigits(num7, num6, cu);
1506 if (num8 >= 0)
1507 {
1508 num4 += num8;
1509 }
1510 else
1511 {
1512 num2 += -num8;
1513 }
1514 if (num4 > num2)
1515 {
1516 num4 -= num2;
1517 num2 = 0;
1518 int num9 = 0;
1519 while (num4 >= 32 && bigInteger[num9] == 0)
1520 {
1521 num4 -= 32;
1522 num9++;
1523 }
1524 if (num9 > 0)
1525 {
1526 bigInteger.ShiftUsRight(num9);
1527 }
1528 uint num10 = bigInteger[0];
1529 for (num9 = 0; num9 < num4 && (num10 & (1L << num9)) == 0L; num9++)
1530 {
1531 }
1532 if (num9 > 0)
1533 {
1534 num4 -= num9;
1535 bigInteger.ShiftRight(num9);
1536 }
1537 }
1538 else
1539 {
1540 num2 -= num4;
1541 num4 = 0;
1542 }
1543 if (num5 > 0)
1544 {
1545 bigInteger2.MulPow5(num5);
1546 }
1547 else if (num3 > 0)
1548 {
1549 bigInteger.MulPow5(num3);
1550 }
1551 if (num4 > 0)
1552 {
1553 bigInteger2.ShiftLeft(num4);
1554 }
1555 else if (num2 > 0)
1556 {
1557 bigInteger.ShiftLeft(num2);
1558 }
1559 int num11 = bigInteger2.CompareTo(bigInteger);
1560 if (num11 == 0)
1561 {
1562 return dbl;
1563 }
1564 if (num11 > 0)
1565 {
1566 if (AddU(ref num7, uint.MaxValue) == 0)
1567 {
1568 AddU(ref num6, uint.MaxValue);
1569 }
1570 bigInteger2.InitFromDigits(num7, num6, 1 + ((num6 != 0) ? 1 : 0));
1571 if (num5 > 0)
1572 {
1573 bigInteger2.MulPow5(num5);
1574 }
1575 if (num4 > 0)
1576 {
1577 bigInteger2.ShiftLeft(num4);
1578 }
1579 num11 = bigInteger2.CompareTo(bigInteger);
1580 if (num11 > 0 || (num11 == 0 && (DblLo(dbl) & (true ? 1u : 0u)) != 0))
1581 {
1582 dbl = BitConverter.Int64BitsToDouble(BitConverter.DoubleToInt64Bits(dbl) - 1);
1583 }
1584 }
1585 else
1586 {
1587 if (AddU(ref num7, u) != 0)
1588 {
1589 AddU(ref num6, 1u);
1590 }
1591 bigInteger2.InitFromDigits(num7, num6, 1 + ((num6 != 0) ? 1 : 0));
1592 if (num5 > 0)
1593 {
1594 bigInteger2.MulPow5(num5);
1595 }
1596 if (num4 > 0)
1597 {
1598 bigInteger2.ShiftLeft(num4);
1599 }
1600 num11 = bigInteger2.CompareTo(bigInteger);
1601 if (num11 < 0 || (num11 == 0 && (DblLo(dbl) & (true ? 1u : 0u)) != 0))
1602 {
1603 dbl = BitConverter.Int64BitsToDouble(BitConverter.DoubleToInt64Bits(dbl) + 1);
1604 }
1605 }
1606 return dbl;
1607 }
static uint AddU(ref uint u1, uint u2)
static uint DblLo(double dbl)
static uint DblHi(double dbl)

References System.Xml.Xsl.XPathConvert.FloatingDecimal._exponent, System.Xml.Xsl.XPathConvert.FloatingDecimal._mantissaSize, System.Xml.Xsl.XPathConvert.AddU(), System.Xml.Xsl.XPathConvert.DblHi(), System.Xml.Xsl.XPathConvert.DblLo(), System.Xml.Dictionary, System.BitConverter.DoubleToInt64Bits(), System.BitConverter.Int64BitsToDouble(), and System.Xml.L.