34 #define PackCategoriesIntoKey(_lhs, _rhs) ((_lhs) * 4 + (_rhs))
38 static_assert(
integerPartWidth % 4 == 0,
"Part width must be divisible by 4!");
100 static inline unsigned int
107 static inline unsigned int
122 unsigned int absExponent;
123 const unsigned int overlargeExponent = 24000;
126 assert(p != end &&
"Exponent has no digits");
128 isNegative = (*p ==
'-');
129 if (*p ==
'-' || *p ==
'+') {
131 assert(p != end &&
"Exponent has no digits");
135 assert(absExponent < 10U &&
"Invalid character in exponent");
137 for (; p !=
end; ++p) {
141 assert(value < 10U &&
"Invalid character in exponent");
143 value += absExponent * 10;
144 if (absExponent >= overlargeExponent) {
145 absExponent = overlargeExponent;
152 assert(p == end &&
"Invalid exponent in exponent");
155 return -(
int) absExponent;
157 return (
int) absExponent;
164 int exponentAdjustment)
166 int unsignedExponent;
167 bool negative, overflow;
170 assert(p != end &&
"Exponent has no digits");
172 negative = *p ==
'-';
173 if (*p ==
'-' || *p ==
'+') {
175 assert(p != end &&
"Exponent has no digits");
178 unsignedExponent = 0;
180 for (; p !=
end; ++p) {
184 assert(value < 10U &&
"Invalid character in exponent");
186 unsignedExponent = unsignedExponent * 10 + value;
187 if (unsignedExponent > 32767) {
193 if (exponentAdjustment > 32767 || exponentAdjustment < -32768)
197 exponent = unsignedExponent;
199 exponent = -exponent;
200 exponent += exponentAdjustment;
201 if (exponent > 32767 || exponent < -32768)
206 exponent = negative ? -32768: 32767;
217 while (p != end && *p ==
'0')
220 if (p != end && *p ==
'.') {
223 assert(end - begin != 1 &&
"Significand has no digits");
225 while (p != end && *p ==
'0')
263 for (; p !=
end; ++p) {
265 assert(dot == end &&
"String contains multiple dots");
275 assert((*p ==
'e' || *p ==
'E') &&
"Invalid character in significand");
276 assert(p != begin &&
"Significand has no digits");
277 assert((dot == end || p - begin != 1) &&
"Significand has no digits");
294 while (p != begin && *p ==
'0');
295 while (p != begin && *p ==
'.');
313 unsigned int digitValue)
315 unsigned int hexDigit;
321 else if (digitValue < 8 && digitValue > 0)
325 while (p != end && (*p ==
'0' || *p ==
'.'))
328 assert(p != end &&
"Invalid trailing hexadecimal fraction!");
344 unsigned int partCount,
373 return lost_fraction;
388 return moreSignificant;
399 HUerrBound(
bool inexactMultiply,
unsigned int HUerr1,
unsigned int HUerr2)
401 assert(HUerr1 < 2 || HUerr2 < 2 || (HUerr1 + HUerr2 < 8));
403 if (HUerr1 + HUerr2 == 0)
404 return inexactMultiply * 2;
406 return inexactMultiply + 2 * (HUerr1 + HUerr2);
415 unsigned int count, partBits;
432 if (part - boundary <= boundary - part)
433 return part - boundary;
435 return boundary - part;
438 if (part == boundary) {
444 }
else if (part == boundary - 1) {
460 static const integerPart firstEightPowers[] = { 1, 5, 25, 125, 625, 3125,
463 pow5s[0] = 78125 * 5;
465 unsigned int partsCount[16] = { 1 };
473 *p1 = firstEightPowers[power & 7];
479 for (
unsigned int n = 0; power; power >>= 1, n++) {
486 pc = partsCount[n - 1];
489 if (pow5[pc - 1] == 0)
499 if (p2[result - 1] == 0)
504 tmp = p1, p1 = p2, p2 = tmp;
522 static const char NaNL[] =
"nan";
523 static const char NaNU[] =
"NAN";
530 const char *hexDigitChars)
532 unsigned int result = count;
538 dst[count] = hexDigitChars[part & 0xf];
582 semantics = ourSemantics;
589 APFloat::freeSignificand()
592 delete [] significand.parts;
596 APFloat::assign(
const APFloat &rhs)
598 assert(semantics == rhs.semantics);
601 category = rhs.category;
602 exponent = rhs.exponent;
604 copySignificand(rhs);
608 APFloat::copySignificand(
const APFloat &rhs)
611 assert(rhs.partCount() >= partCount());
620 void APFloat::makeNaN(
bool SNaN,
bool Negative,
const APInt *fill)
626 unsigned numParts = partCount();
636 unsigned bitsToPreserve = semantics->
precision - 1;
637 unsigned part = bitsToPreserve / 64;
638 bitsToPreserve %= 64;
639 significand[part] &= ((1ULL << bitsToPreserve) - 1);
640 for (part++; part != numParts; ++part)
641 significand[part] = 0;
644 unsigned QNaNBit = semantics->
precision - 2;
670 value.makeNaN(SNaN, Negative, fill);
678 if (semantics != rhs.semantics) {
680 initialize(rhs.semantics);
692 semantics = rhs.semantics;
693 significand = rhs.significand;
694 exponent = rhs.exponent;
695 category = rhs.category;
698 rhs.semantics = &
Bogus;
715 significandMSB() == 0;
718 bool APFloat::isSignificandAllOnes()
const {
722 const unsigned PartCount = partCount();
723 for (
unsigned i = 0; i < PartCount - 1; i++)
728 const unsigned NumHighBits =
731 "fill than integerPartWidth");
734 if (~(Parts[PartCount - 1] | HighBitFill))
740 bool APFloat::isSignificandAllZeros()
const {
744 const unsigned PartCount = partCount();
746 for (
unsigned i = 0; i < PartCount - 1; i++)
750 const unsigned NumHighBits =
753 "clear than integerPartWidth");
756 if (Parts[PartCount - 1] & HighBitMask)
767 && isSignificandAllOnes();
774 if (semantics != rhs.semantics ||
775 category != rhs.category ||
786 for (; i>0; i--, p++, q++) {
795 initialize(&ourSemantics);
800 significandParts()[0] = value;
805 initialize(&ourSemantics);
812 initialize(&ourSemantics);
816 initialize(&ourSemantics);
821 initialize(rhs.semantics);
826 *
this = std::move(rhs);
840 APFloat::partCount()
const
852 APFloat::significandParts()
const
854 return const_cast<APFloat *
>(
this)->significandParts();
858 APFloat::significandParts()
861 return significand.parts;
863 return &significand.part;
867 APFloat::zeroSignificand()
874 APFloat::incrementSignificand()
887 APFloat::addSignificand(
const APFloat &rhs)
891 parts = significandParts();
893 assert(semantics == rhs.semantics);
894 assert(exponent == rhs.exponent);
896 return APInt::tcAdd(parts, rhs.significandParts(), 0, partCount());
906 parts = significandParts();
908 assert(semantics == rhs.semantics);
909 assert(exponent == rhs.exponent);
919 APFloat::multiplySignificand(
const APFloat &rhs,
const APFloat *addend)
922 unsigned int partsCount, newPartsCount, precision;
929 assert(semantics == rhs.semantics);
937 if (newPartsCount > 4)
940 fullSignificand = scratch;
942 lhsSignificand = significandParts();
943 partsCount = partCount();
946 rhs.significandParts(), partsCount, partsCount);
949 omsb =
APInt::tcMSB(fullSignificand, newPartsCount) + 1;
950 exponent += rhs.exponent;
968 Significand savedSignificand = significand;
972 unsigned int extendedPrecision;
975 extendedPrecision = 2 * precision + 1;
976 if (omsb != extendedPrecision - 1) {
977 assert(extendedPrecision > omsb);
979 (extendedPrecision - 1) - omsb);
980 exponent -= (extendedPrecision - 1) - omsb;
984 extendedSemantics = *semantics;
985 extendedSemantics.
precision = extendedPrecision;
987 if (newPartsCount == 1)
988 significand.part = fullSignificand[0];
990 significand.parts = fullSignificand;
991 semantics = &extendedSemantics;
993 APFloat extendedAddend(*addend);
994 status = extendedAddend.convert(extendedSemantics,
rmTowardZero, &ignored);
995 assert(status ==
opOK);
1001 lost_fraction = extendedAddend.shiftSignificandRight(1);
1003 "Lost precision while shifting addend for fused-multiply-add.");
1005 lost_fraction = addOrSubtractSignificand(extendedAddend,
false);
1008 if (newPartsCount == 1)
1009 fullSignificand[0] = significand.part;
1010 significand = savedSignificand;
1011 semantics = savedSemantics;
1013 omsb =
APInt::tcMSB(fullSignificand, newPartsCount) + 1;
1020 exponent -= precision + 1;
1028 if (omsb > precision) {
1029 unsigned int bits, significantParts;
1032 bits = omsb - precision;
1034 lf =
shiftRight(fullSignificand, significantParts, bits);
1041 if (newPartsCount > 4)
1042 delete [] fullSignificand;
1044 return lost_fraction;
1049 APFloat::divideSignificand(
const APFloat &rhs)
1051 unsigned int bit, i, partsCount;
1057 assert(semantics == rhs.semantics);
1059 lhsSignificand = significandParts();
1060 rhsSignificand = rhs.significandParts();
1061 partsCount = partCount();
1068 divisor = dividend + partsCount;
1071 for (i = 0; i < partsCount; i++) {
1072 dividend[i] = lhsSignificand[i];
1073 divisor[i] = rhsSignificand[i];
1074 lhsSignificand[i] = 0;
1077 exponent -= rhs.exponent;
1079 unsigned int precision = semantics->
precision;
1082 bit = precision -
APInt::tcMSB(divisor, partsCount) - 1;
1089 bit = precision -
APInt::tcMSB(dividend, partsCount) - 1;
1105 for (bit = precision; bit; bit -= 1) {
1129 return lost_fraction;
1133 APFloat::significandMSB()
const
1139 APFloat::significandLSB()
const
1146 APFloat::shiftSignificandRight(
unsigned int bits)
1153 return shiftRight(significandParts(), partCount(), bits);
1158 APFloat::shiftSignificandLeft(
unsigned int bits)
1160 assert(bits < semantics->precision);
1163 unsigned int partsCount = partCount();
1173 APFloat::compareAbsoluteValue(
const APFloat &rhs)
const
1177 assert(semantics == rhs.semantics);
1181 compare = exponent - rhs.exponent;
1191 else if (compare < 0)
1200 APFloat::handleOverflow(roundingMode rounding_mode)
1226 APFloat::roundAwayFromZero(roundingMode rounding_mode,
1228 unsigned int bit)
const
1236 switch (rounding_mode) {
1263 APFloat::normalize(roundingMode rounding_mode,
1273 omsb = significandMSB() + 1;
1279 exponentChange = omsb - semantics->
precision;
1283 if (exponent + exponentChange > semantics->
maxExponent)
1284 return handleOverflow(rounding_mode);
1288 if (exponent + exponentChange < semantics->minExponent)
1289 exponentChange = semantics->
minExponent - exponent;
1292 if (exponentChange < 0) {
1295 shiftSignificandLeft(-exponentChange);
1300 if (exponentChange > 0) {
1304 lf = shiftSignificandRight(exponentChange);
1309 if (omsb > (
unsigned) exponentChange)
1310 omsb -= exponentChange;
1330 if (roundAwayFromZero(rounding_mode, lost_fraction, 0)) {
1334 incrementSignificand();
1335 omsb = significandMSB() + 1;
1338 if (omsb == (
unsigned) semantics->
precision + 1) {
1348 shiftSignificandRight(1);
1360 assert(omsb < semantics->precision);
1371 APFloat::addOrSubtractSpecials(
const APFloat &rhs,
bool subtract)
1391 sign = rhs.sign ^ subtract;
1393 copySignificand(rhs);
1414 if (((sign ^ rhs.sign)!=0) != subtract) {
1428 APFloat::addOrSubtractSignificand(
const APFloat &rhs,
bool subtract)
1436 subtract ^=
static_cast<bool>(sign ^ rhs.sign);
1439 bits = exponent - rhs.exponent;
1447 reverse = compareAbsoluteValue(temp_rhs) ==
cmpLessThan;
1449 }
else if (bits > 0) {
1450 lost_fraction = temp_rhs.shiftSignificandRight(bits - 1);
1451 shiftSignificandLeft(1);
1454 lost_fraction = shiftSignificandRight(-bits - 1);
1455 temp_rhs.shiftSignificandLeft(1);
1460 carry = temp_rhs.subtractSignificand
1462 copySignificand(temp_rhs);
1465 carry = subtractSignificand
1484 lost_fraction = temp_rhs.shiftSignificandRight(bits);
1485 carry = addSignificand(temp_rhs);
1487 lost_fraction = shiftSignificandRight(-bits);
1488 carry = addSignificand(rhs);
1496 return lost_fraction;
1500 APFloat::multiplySpecials(
const APFloat &rhs)
1518 copySignificand(rhs);
1544 APFloat::divideSpecials(
const APFloat &rhs)
1554 copySignificand(rhs);
1585 APFloat::modSpecials(
const APFloat &rhs)
1605 copySignificand(rhs);
1645 APFloat::addOrSubtract(
const APFloat &rhs, roundingMode rounding_mode,
1650 fs = addOrSubtractSpecials(rhs, subtract);
1656 lost_fraction = addOrSubtractSignificand(rhs, subtract);
1657 fs = normalize(rounding_mode, lost_fraction);
1666 if (category ==
fcZero) {
1667 if (rhs.category !=
fcZero || (sign == rhs.sign) == subtract)
1678 return addOrSubtract(rhs, rounding_mode,
false);
1685 return addOrSubtract(rhs, rounding_mode,
true);
1695 fs = multiplySpecials(rhs);
1698 lostFraction lost_fraction = multiplySignificand(rhs,
nullptr);
1699 fs = normalize(rounding_mode, lost_fraction);
1714 fs = divideSpecials(rhs);
1718 fs = normalize(rounding_mode, lost_fraction);
1732 unsigned int origSign = sign;
1738 int parts = partCount();
1768 fs = modSpecials(rhs);
1772 unsigned int origSign = sign;
1778 int parts = partCount();
1790 fs = V.
multiply(rhs, rounding_mode);
1812 sign ^= multiplicand.sign;
1821 lost_fraction = multiplySignificand(multiplicand, &addend);
1822 fs = normalize(rounding_mode, lost_fraction);
1832 fs = multiplySpecials(multiplicand);
1842 fs = addOrSubtract(addend, rounding_mode,
false);
1866 APFloat MagicConstant(*semantics);
1877 fs =
add(MagicConstant, rounding_mode);
1881 fs =
subtract(MagicConstant, rounding_mode);
1897 assert(semantics == rhs.semantics);
1929 if (sign == rhs.sign)
1944 if (sign != rhs.sign) {
1951 result = compareAbsoluteValue(rhs);
1976 unsigned int newPartCount, oldPartCount;
1983 oldPartCount = partCount();
1986 bool X86SpecialNan =
false;
1989 (!(*significandParts() & 0x8000000000000000ULL) ||
1990 !(*significandParts() & 0x4000000000000000ULL))) {
1993 X86SpecialNan =
true;
2002 int exponentChange = significandMSB() + 1 - fromSemantics.
precision;
2003 if (exponent + exponentChange < toSemantics.
minExponent)
2004 exponentChange = toSemantics.
minExponent - exponent;
2005 if (exponentChange < shift)
2006 exponentChange = shift;
2007 if (exponentChange < 0) {
2008 shift -= exponentChange;
2009 exponent += exponentChange;
2015 lostFraction =
shiftRight(significandParts(), oldPartCount, -shift);
2018 if (newPartCount > oldPartCount) {
2026 significand.parts = newParts;
2027 }
else if (newPartCount == 1 && oldPartCount != 1) {
2031 newPart = significandParts()[0];
2033 significand.part = newPart;
2037 semantics = &toSemantics;
2045 fs = normalize(rounding_mode, lostFraction);
2046 *losesInfo = (fs !=
opOK);
2047 }
else if (category ==
fcNaN) {
2048 *losesInfo = lostFraction !=
lfExactlyZero || X86SpecialNan;
2079 APFloat::convertToSignExtendedInteger(
integerPart *parts,
unsigned int width,
2081 roundingMode rounding_mode,
2082 bool *isExact)
const
2086 unsigned int dstPartsCount, truncatedBits;
2096 if (category ==
fcZero) {
2103 src = significandParts();
2112 truncatedBits = semantics->
precision -1U - exponent;
2116 unsigned int bits = exponent + 1U;
2122 if (bits < semantics->precision) {
2124 truncatedBits = semantics->
precision - bits;
2136 if (truncatedBits) {
2140 roundAwayFromZero(rounding_mode, lost_fraction, truncatedBits)) {
2149 unsigned int omsb =
APInt::tcMSB(parts, dstPartsCount) + 1;
2160 if (omsb == width &&
APInt::tcLSB(parts, dstPartsCount) + 1 != omsb)
2170 if (omsb >= width + !isSigned)
2197 fs = convertToSignExtendedInteger(parts, width, isSigned, rounding_mode,
2201 unsigned int bits, dstPartsCount;
2205 if (category ==
fcNaN)
2210 bits = width - isSigned;
2213 if (sign && isSigned)
2231 parts.data(), bitWidth, result.
isSigned(), rounding_mode, isExact);
2233 result =
APInt(bitWidth, parts);
2241 APFloat::convertFromUnsignedParts(
const integerPart *src,
2242 unsigned int srcCount,
2243 roundingMode rounding_mode)
2245 unsigned int omsb, precision, dstCount;
2251 dst = significandParts();
2252 dstCount = partCount();
2257 if (precision <= omsb) {
2258 exponent = omsb - 1;
2263 exponent = precision - 1;
2268 return normalize(rounding_mode, lost_fraction);
2285 return convertFromUnsignedParts(api.
getRawData(), partCount, rounding_mode);
2293 unsigned int srcCount,
2308 status = convertFromUnsignedParts(copy, srcCount, rounding_mode);
2312 status = convertFromUnsignedParts(src, srcCount, rounding_mode);
2321 unsigned int width,
bool isSigned,
2333 return convertFromUnsignedParts(api.
getRawData(), partCount, rounding_mode);
2337 APFloat::convertFromHexadecimalString(
StringRef s, roundingMode rounding_mode)
2346 unsigned partsCount = partCount();
2348 bool computedTrailingFraction =
false;
2361 assert(dot == end &&
"String contains multiple dots");
2367 if (hex_value == -1U)
2377 }
else if (!computedTrailingFraction) {
2379 computedTrailingFraction =
true;
2384 assert(p != end &&
"Hex strings require an exponent");
2385 assert((*p ==
'p' || *p ==
'P') &&
"Invalid character in significand");
2386 assert(p != begin &&
"Significand has no digits");
2387 assert((dot == end || p - begin != 1) &&
"Significand has no digits");
2390 if (p != firstSignificantDigit) {
2399 expAdjustment =
static_cast<int>(dot - firstSignificantDigit);
2400 if (expAdjustment < 0)
2402 expAdjustment = expAdjustment * 4 - 1;
2413 return normalize(rounding_mode, lost_fraction);
2417 APFloat::roundSignificandWithExponent(
const integerPart *decSigParts,
2418 unsigned sigPartCount,
int exp,
2419 roundingMode rounding_mode)
2421 unsigned int parts, pow5PartCount;
2432 pow5PartCount =
powerOf5(pow5Parts, exp >= 0 ? exp: -exp);
2434 for (;; parts *= 2) {
2436 unsigned int excessPrecision, truncatedBits;
2438 calcSemantics.
precision = parts * integerPartWidth - 1;
2440 truncatedBits = excessPrecision;
2445 sigStatus = decSig.convertFromUnsignedParts(decSigParts, sigPartCount,
2447 powStatus = pow5.convertFromUnsignedParts(pow5Parts, pow5PartCount,
2450 decSig.exponent += exp;
2454 unsigned int powHUerr;
2458 calcLostFraction = decSig.multiplySignificand(pow5,
nullptr);
2459 powHUerr = powStatus !=
opOK;
2461 calcLostFraction = decSig.divideSignificand(pow5);
2464 excessPrecision += (semantics->
minExponent - decSig.exponent);
2465 truncatedBits = excessPrecision;
2466 if (excessPrecision > calcSemantics.
precision)
2467 excessPrecision = calcSemantics.
precision;
2476 (decSig.significandParts(), calcSemantics.
precision - 1) == 1);
2481 excessPrecision, isNearest);
2484 if (HUdistance >= HUerr) {
2485 APInt::tcExtract(significandParts(), partCount(), decSig.significandParts(),
2486 calcSemantics.
precision - excessPrecision,
2491 exponent = (decSig.exponent + semantics->
precision
2492 - (calcSemantics.
precision - excessPrecision));
2496 return normalize(rounding_mode, calcLostFraction);
2502 APFloat::convertFromDecimalString(
StringRef str, roundingMode rounding_mode)
2542 fs = handleOverflow(rounding_mode);
2560 fs = handleOverflow(rounding_mode);
2563 unsigned int partCount;
2587 if (p == str.
end()) {
2592 assert(decValue < 10U &&
"Invalid character in significand");
2594 val = val * 10 + decValue;
2601 partCount, partCount + 1,
false);
2605 if (decSignificand[partCount])
2610 fs = roundSignificandWithExponent(decSignificand, partCount,
2613 delete [] decSignificand;
2620 APFloat::convertFromStringSpecials(
StringRef str) {
2632 makeNaN(
false,
false);
2637 makeNaN(
false,
true);
2647 assert(!str.
empty() &&
"Invalid string length");
2650 if (convertFromStringSpecials(str))
2655 size_t slen = str.
size();
2656 sign = *p ==
'-' ? 1 : 0;
2657 if (*p ==
'-' || *p ==
'+') {
2660 assert(slen &&
"String has no digits");
2663 if (slen >= 2 && p[0] ==
'0' && (p[1] ==
'x' || p[1] ==
'X')) {
2664 assert(slen - 2 &&
"Invalid string");
2665 return convertFromHexadecimalString(
StringRef(p + 2, slen - 2),
2669 return convertFromDecimalString(
StringRef(p, slen), rounding_mode);
2709 dst +=
sizeof infinityL - 1;
2714 dst +=
sizeof NaNU - 1;
2719 *dst++ = upperCase ?
'X':
'x';
2721 if (hexDigits > 1) {
2723 memset (dst,
'0', hexDigits - 1);
2724 dst += hexDigits - 1;
2726 *dst++ = upperCase ?
'P':
'p';
2731 dst = convertNormalToHexString (dst, hexDigits, upperCase, rounding_mode);
2737 return static_cast<unsigned int>(dst - p);
2745 APFloat::convertNormalToHexString(
char *dst,
unsigned int hexDigits,
2747 roundingMode rounding_mode)
const
2749 unsigned int count, valueBits, shift, partsCount, outputDigits;
2750 const char *hexDigitChars;
2756 *dst++ = upperCase ?
'X':
'x';
2761 significand = significandParts();
2762 partsCount = partCount();
2771 outputDigits = (valueBits - significandLSB () + 3) / 4;
2777 if (hexDigits < outputDigits) {
2783 bits = valueBits - hexDigits * 4;
2785 roundUp = roundAwayFromZero(rounding_mode, fraction, bits);
2787 outputDigits = hexDigits;
2795 count = (valueBits + integerPartWidth - 1) / integerPartWidth;
2797 while (outputDigits && count) {
2801 if (--count == partsCount)
2804 part = significand[count] << shift;
2807 part |= significand[count - 1] >> (integerPartWidth - shift);
2810 unsigned int curDigits = integerPartWidth / 4;
2812 if (curDigits > outputDigits)
2813 curDigits = outputDigits;
2814 dst +=
partAsHex (dst, part, curDigits, hexDigitChars);
2815 outputDigits -= curDigits;
2825 }
while (*q ==
'0');
2829 memset (dst,
'0', outputDigits);
2830 dst += outputDigits;
2843 *dst++ = upperCase ?
'P':
'p';
2852 Arg.
isNaN() ? (uint8_t)0 : (uint8_t)Arg.sign,
2856 return hash_combine((uint8_t)Arg.category, (uint8_t)Arg.sign,
2859 Arg.significandParts(),
2860 Arg.significandParts() + Arg.partCount()));
2873 APFloat::convertF80LongDoubleAPFloatToAPInt()
const
2876 assert(partCount()==2);
2878 uint64_t myexponent, mysignificand;
2881 myexponent = exponent+16383;
2882 mysignificand = significandParts()[0];
2883 if (myexponent==1 && !(mysignificand & 0x8000000000000000ULL))
2885 }
else if (category==
fcZero) {
2889 myexponent = 0x7fff;
2890 mysignificand = 0x8000000000000000ULL;
2892 assert(category ==
fcNaN &&
"Unknown category");
2893 myexponent = 0x7fff;
2894 mysignificand = significandParts()[0];
2898 words[0] = mysignificand;
2899 words[1] = ((uint64_t)(sign & 1) << 15) |
2900 (myexponent & 0x7fffLL);
2901 return APInt(80, words);
2905 APFloat::convertPPCDoubleDoubleAPFloatToAPInt()
const
2908 assert(partCount()==2);
2924 assert(fs ==
opOK && !losesInfo);
2931 words[0] = *u.convertDoubleAPFloatToAPInt().getRawData();
2937 if (u.isFiniteNonZero() && losesInfo) {
2939 assert(fs ==
opOK && !losesInfo);
2945 assert(fs ==
opOK && !losesInfo);
2947 words[1] = *v.convertDoubleAPFloatToAPInt().getRawData();
2952 return APInt(128, words);
2956 APFloat::convertQuadrupleAPFloatToAPInt()
const
2959 assert(partCount()==2);
2961 uint64_t myexponent, mysignificand, mysignificand2;
2964 myexponent = exponent+16383;
2965 mysignificand = significandParts()[0];
2966 mysignificand2 = significandParts()[1];
2967 if (myexponent==1 && !(mysignificand2 & 0x1000000000000LL))
2969 }
else if (category==
fcZero) {
2971 mysignificand = mysignificand2 = 0;
2973 myexponent = 0x7fff;
2974 mysignificand = mysignificand2 = 0;
2976 assert(category ==
fcNaN &&
"Unknown category!");
2977 myexponent = 0x7fff;
2978 mysignificand = significandParts()[0];
2979 mysignificand2 = significandParts()[1];
2983 words[0] = mysignificand;
2984 words[1] = ((uint64_t)(sign & 1) << 63) |
2985 ((myexponent & 0x7fff) << 48) |
2986 (mysignificand2 & 0xffffffffffffLL);
2988 return APInt(128, words);
2992 APFloat::convertDoubleAPFloatToAPInt()
const
2995 assert(partCount()==1);
2997 uint64_t myexponent, mysignificand;
3000 myexponent = exponent+1023;
3001 mysignificand = *significandParts();
3002 if (myexponent==1 && !(mysignificand & 0x10000000000000LL))
3004 }
else if (category==
fcZero) {
3011 assert(category ==
fcNaN &&
"Unknown category!");
3013 mysignificand = *significandParts();
3016 return APInt(64, ((((uint64_t)(sign & 1) << 63) |
3017 ((myexponent & 0x7ff) << 52) |
3018 (mysignificand & 0xfffffffffffffLL))));
3022 APFloat::convertFloatAPFloatToAPInt()
const
3025 assert(partCount()==1);
3027 uint32_t myexponent, mysignificand;
3030 myexponent = exponent+127;
3031 mysignificand = (uint32_t)*significandParts();
3032 if (myexponent == 1 && !(mysignificand & 0x800000))
3034 }
else if (category==
fcZero) {
3041 assert(category ==
fcNaN &&
"Unknown category!");
3043 mysignificand = (uint32_t)*significandParts();
3046 return APInt(32, (((sign&1) << 31) | ((myexponent&0xff) << 23) |
3047 (mysignificand & 0x7fffff)));
3051 APFloat::convertHalfAPFloatToAPInt()
const
3054 assert(partCount()==1);
3056 uint32_t myexponent, mysignificand;
3059 myexponent = exponent+15;
3060 mysignificand = (uint32_t)*significandParts();
3061 if (myexponent == 1 && !(mysignificand & 0x400))
3063 }
else if (category==
fcZero) {
3070 assert(category ==
fcNaN &&
"Unknown category!");
3072 mysignificand = (uint32_t)*significandParts();
3075 return APInt(16, (((sign&1) << 15) | ((myexponent&0x1f) << 10) |
3076 (mysignificand & 0x3ff)));
3087 return convertHalfAPFloatToAPInt();
3090 return convertFloatAPFloatToAPInt();
3093 return convertDoubleAPFloatToAPInt();
3096 return convertQuadrupleAPFloatToAPInt();
3099 return convertPPCDoubleDoubleAPFloatToAPInt();
3103 return convertF80LongDoubleAPFloatToAPInt();
3110 "Float semantics are not IEEEsingle");
3119 "Float semantics are not IEEEdouble");
3132 APFloat::initFromF80LongDoubleAPInt(
const APInt &api)
3137 uint64_t myexponent = (i2 & 0x7fff);
3138 uint64_t mysignificand = i1;
3141 assert(partCount()==2);
3143 sign =
static_cast<unsigned int>(i2>>15);
3144 if (myexponent==0 && mysignificand==0) {
3147 }
else if (myexponent==0x7fff && mysignificand==0x8000000000000000ULL) {
3150 }
else if (myexponent==0x7fff && mysignificand!=0x8000000000000000ULL) {
3153 significandParts()[0] = mysignificand;
3154 significandParts()[1] = 0;
3157 exponent = myexponent - 16383;
3158 significandParts()[0] = mysignificand;
3159 significandParts()[1] = 0;
3166 APFloat::initFromPPCDoubleDoubleAPInt(
const APInt &api)
3175 initFromDoubleAPInt(
APInt(64, i1));
3177 assert(fs ==
opOK && !losesInfo);
3184 assert(fs ==
opOK && !losesInfo);
3192 APFloat::initFromQuadrupleAPInt(
const APInt &api)
3197 uint64_t myexponent = (i2 >> 48) & 0x7fff;
3198 uint64_t mysignificand = i1;
3199 uint64_t mysignificand2 = i2 & 0xffffffffffffLL;
3202 assert(partCount()==2);
3204 sign =
static_cast<unsigned int>(i2>>63);
3205 if (myexponent==0 &&
3206 (mysignificand==0 && mysignificand2==0)) {
3209 }
else if (myexponent==0x7fff &&
3210 (mysignificand==0 && mysignificand2==0)) {
3213 }
else if (myexponent==0x7fff &&
3214 (mysignificand!=0 || mysignificand2 !=0)) {
3217 significandParts()[0] = mysignificand;
3218 significandParts()[1] = mysignificand2;
3221 exponent = myexponent - 16383;
3222 significandParts()[0] = mysignificand;
3223 significandParts()[1] = mysignificand2;
3227 significandParts()[1] |= 0x1000000000000LL;
3232 APFloat::initFromDoubleAPInt(
const APInt &api)
3236 uint64_t myexponent = (i >> 52) & 0x7ff;
3237 uint64_t mysignificand = i & 0xfffffffffffffLL;
3240 assert(partCount()==1);
3242 sign =
static_cast<unsigned int>(i>>63);
3243 if (myexponent==0 && mysignificand==0) {
3246 }
else if (myexponent==0x7ff && mysignificand==0) {
3249 }
else if (myexponent==0x7ff && mysignificand!=0) {
3252 *significandParts() = mysignificand;
3255 exponent = myexponent - 1023;
3256 *significandParts() = mysignificand;
3260 *significandParts() |= 0x10000000000000LL;
3265 APFloat::initFromFloatAPInt(
const APInt & api)
3269 uint32_t myexponent = (i >> 23) & 0xff;
3270 uint32_t mysignificand = i & 0x7fffff;
3273 assert(partCount()==1);
3276 if (myexponent==0 && mysignificand==0) {
3279 }
else if (myexponent==0xff && mysignificand==0) {
3282 }
else if (myexponent==0xff && mysignificand!=0) {
3285 *significandParts() = mysignificand;
3288 exponent = myexponent - 127;
3289 *significandParts() = mysignificand;
3293 *significandParts() |= 0x800000;
3298 APFloat::initFromHalfAPInt(
const APInt & api)
3302 uint32_t myexponent = (i >> 10) & 0x1f;
3303 uint32_t mysignificand = i & 0x3ff;
3306 assert(partCount()==1);
3309 if (myexponent==0 && mysignificand==0) {
3312 }
else if (myexponent==0x1f && mysignificand==0) {
3315 }
else if (myexponent==0x1f && mysignificand!=0) {
3318 *significandParts() = mysignificand;
3321 exponent = myexponent - 15;
3322 *significandParts() = mysignificand;
3326 *significandParts() |= 0x400;
3338 return initFromHalfAPInt(api);
3340 return initFromFloatAPInt(api);
3342 return initFromDoubleAPInt(api);
3344 return initFromF80LongDoubleAPInt(api);
3346 return initFromQuadrupleAPInt(api);
3348 return initFromPPCDoubleDoubleAPInt(api);
3380 void APFloat::makeLargest(
bool Negative) {
3391 unsigned PartCount = partCount();
3392 memset(significand, 0xFF,
sizeof(
integerPart)*(PartCount - 1));
3396 const unsigned NumUnusedHighBits =
3397 PartCount*integerPartWidth - semantics->
precision;
3405 void APFloat::makeSmallest(
bool Negative) {
3423 Val.makeLargest(Negative);
3433 Val.makeSmallest(Negative);
3446 Val.zeroSignificand();
3447 Val.sign = Negative;
3456 initFromAPInt(&Sem, API);
3474 void AdjustToPrecision(
APInt &significand,
3475 int &exp,
unsigned FormatPrecision) {
3479 unsigned bitsRequired = (FormatPrecision * 196 + 58) / 59;
3481 if (bits <= bitsRequired)
return;
3483 unsigned tensRemovable = (bits - bitsRequired) * 59 / 196;
3484 if (!tensRemovable)
return;
3486 exp += tensRemovable;
3491 if (tensRemovable & 1)
3493 tensRemovable >>= 1;
3494 if (!tensRemovable)
break;
3498 significand = significand.
udiv(divisor);
3506 int &exp,
unsigned FormatPrecision) {
3507 unsigned N = buffer.
size();
3508 if (N <= FormatPrecision)
return;
3511 unsigned FirstSignificant = N - FormatPrecision;
3518 if (buffer[FirstSignificant - 1] <
'5') {
3519 while (FirstSignificant < N && buffer[FirstSignificant] ==
'0')
3522 exp += FirstSignificant;
3523 buffer.
erase(&buffer[0], &buffer[FirstSignificant]);
3529 for (
unsigned I = FirstSignificant;
I !=
N; ++
I) {
3530 if (buffer[
I] ==
'9') {
3539 if (FirstSignificant == N) {
3540 exp += FirstSignificant;
3546 exp += FirstSignificant;
3547 buffer.
erase(&buffer[0], &buffer[FirstSignificant]);
3552 unsigned FormatPrecision,
3553 unsigned FormatMaxPadding)
const {
3557 return append(Str,
"-Inf");
3559 return append(Str,
"+Inf");
3567 if (!FormatMaxPadding)
3588 if (!FormatPrecision) {
3596 FormatPrecision = 2 + semantics->
precision * 59 / 196;
3601 exp += trailingZeros;
3602 significand = significand.
lshr(trailingZeros);
3607 }
else if (exp > 0) {
3610 significand <<= exp;
3624 unsigned precision = semantics->
precision + (137 * texp + 136) / 59;
3628 significand = significand.
zext(precision);
3629 APInt five_to_the_i(precision, 5);
3631 if (texp & 1) significand *= five_to_the_i;
3635 five_to_the_i *= five_to_the_i;
3639 AdjustToPrecision(significand, exp, FormatPrecision);
3645 APInt ten(precision, 10);
3646 APInt digit(precision, 0);
3648 bool inTrail =
true;
3649 while (significand != 0) {
3657 if (inTrail && !d) exp++;
3664 assert(!buffer.
empty() &&
"no characters in buffer!");
3668 AdjustToPrecision(buffer, exp, FormatPrecision);
3670 unsigned NDigits = buffer.
size();
3673 bool FormatScientific;
3674 if (!FormatMaxPadding)
3675 FormatScientific =
true;
3681 FormatScientific = ((
unsigned) exp > FormatMaxPadding ||
3682 NDigits + (
unsigned) exp > FormatPrecision);
3685 int MSD = exp + (
int) (NDigits - 1);
3688 FormatScientific =
false;
3692 FormatScientific = ((
unsigned) -MSD) > FormatMaxPadding;
3698 if (FormatScientific) {
3699 exp += (NDigits - 1);
3706 for (
unsigned I = 1;
I != NDigits; ++
I)
3711 if (exp < 0) exp = -exp;
3714 expbuf.
push_back((
char) (
'0' + (exp % 10)));
3717 for (
unsigned I = 0, E = expbuf.
size();
I != E; ++
I)
3724 for (
unsigned I = 0;
I != NDigits; ++
I)
3734 int NWholeDigits = exp + (
int) NDigits;
3737 if (NWholeDigits > 0) {
3738 for (; I != (
unsigned) NWholeDigits; ++
I)
3742 unsigned NZeros = 1 + (
unsigned) -NWholeDigits;
3746 for (
unsigned Z = 1; Z != NZeros; ++Z)
3750 for (; I != NDigits; ++
I)
3761 if (significandLSB() != semantics->
precision - 1)
3765 APFloat reciprocal(*semantics, 1ULL);
3775 reciprocal.significandLSB() == reciprocal.semantics->
precision - 1);
3825 makeSmallest(
false);
3853 bool WillCrossBinadeBoundary =
3854 exponent != semantics->
minExponent && isSignificandAllZeros();
3872 if (WillCrossBinadeBoundary) {
3888 bool WillCrossBinadeBoundary = !
isDenormal() && isSignificandAllOnes();
3890 if (WillCrossBinadeBoundary) {
3895 "We can not increment an exponent beyond the maxExponent allowed"
3896 " by the given floating point semantics.");
3899 incrementSignificand();
3913 APFloat::makeInf(
bool Negative) {
3921 APFloat::makeZero(
bool Negative) {
3934 if (Exp > (MaxExp - X.exponent))
3937 if (Exp < (MinExp - X.exponent))
opStatus divide(const APFloat &, roundingMode)
void push_back(const T &Elt)
static void tcExtract(integerPart *, unsigned int dstCount, const integerPart *, unsigned int srcBits, unsigned int srcLSB)
Copy the bit vector of width srcBITS from SRC, starting at bit srcLSB, to DST, of dstCOUNT parts...
const_iterator end(StringRef path)
Get end iterator over path.
static APInt getAllOnesValue(unsigned numBits)
Get the all-ones value.
uint64_t getZExtValue() const
Get zero extended value.
static void tcSetLeastSignificantBits(integerPart *, unsigned int, unsigned int bits)
Set the least significant BITS and clear the rest.
const unsigned int maxPowerOfFiveParts
bool isNaN() const
Returns true if and only if the float is a quiet or signaling NaN.
APFloat & operator=(const APFloat &)
size_t size() const
size - Get the string size.
void Profile(FoldingSetNodeID &NID) const
Used to insert APFloat objects, or objects that contain APFloat objects, into FoldingSets.
static char * writeSignedDecimal(char *dst, int value)
static const fltSemantics IEEEdouble
static int totalExponent(StringRef::iterator p, StringRef::iterator end, int exponentAdjustment)
static lostFraction lostFractionThroughTruncation(const integerPart *parts, unsigned int partCount, unsigned int bits)
APFloat(const fltSemantics &)
static unsigned int decDigitValue(unsigned int c)
static unsigned int HUerrBound(bool inexactMultiply, unsigned int HUerr1, unsigned int HUerr2)
static void interpretDecimal(StringRef::iterator begin, StringRef::iterator end, decimalInfo *D)
opStatus
IEEE-754R 7: Default exception handling.
const_iterator begin(StringRef path)
Get begin iterator over path.
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
static lostFraction shiftRight(integerPart *dst, unsigned int parts, unsigned int bits)
static integerPart tcIncrement(integerPart *, unsigned int)
Increment a bignum in-place. Return the carry flag.
static const fltSemantics Bogus
A Pseudo fltsemantic used to construct APFloats that cannot conflict with anything real...
bool isSignaling() const
Returns true if and only if the float is a signaling NaN.
bool isFiniteNonZero() const
static unsigned int tcLSB(const integerPart *, unsigned int)
Returns the bit number of the least or most significant set bit of a number.
opStatus convertFromString(StringRef, roundingMode)
bool bitwiseIsEqual(const APFloat &) const
Bitwise comparison for equality (QNaNs compare equal, 0!=-0).
bool isNegative() const
Determine sign of this APInt.
static const fltSemantics x87DoubleExtended
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
signed short ExponentType
A signed type to represent a floating point numbers unbiased exponent.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
opStatus convertToInteger(integerPart *, unsigned int, bool, roundingMode, bool *) const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static int tcMultiplyPart(integerPart *dst, const integerPart *src, integerPart multiplier, integerPart carry, unsigned int srcParts, unsigned int dstParts, bool add)
DST += SRC * MULTIPLIER + PART if add is true DST = SRC * MULTIPLIER + PART if add is false...
APInt LLVM_ATTRIBUTE_UNUSED_RESULT lshr(unsigned shiftAmt) const
Logical right-shift function.
static bool tcIsZero(const integerPart *, unsigned int)
Returns true if a bignum is zero, false otherwise.
Number of individual test Apply this number of consecutive mutations to each input exit after the first new interesting input is found the minimized corpus is saved into the first input directory Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
static const fltSemantics IEEEquad
static void tcNegate(integerPart *, unsigned int)
Negate a bignum in-place.
void copySign(const APFloat &)
static void tcAssign(integerPart *, const integerPart *, unsigned int)
Assign one bignum to another.
uninitializedTag
Convenience enum used to construct an uninitialized APFloat.
opStatus convertFromZeroExtendedInteger(const integerPart *, unsigned int, bool, roundingMode)
bool isFinite() const
Returns true if and only if the current value is zero, subnormal, or normal.
static void tcShiftLeft(integerPart *, unsigned int parts, unsigned int count)
Shift a bignum left COUNT bits.
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
static APFloat getSmallest(const fltSemantics &Sem, bool Negative=false)
Returns the smallest (by magnitude) finite number in the given semantics.
static int tcExtractBit(const integerPart *, unsigned int bit)
Extract the given bit of a bignum; returns 0 or 1. Zero-based.
static lostFraction trailingHexadecimalFraction(StringRef::iterator p, StringRef::iterator end, unsigned int digitValue)
static void tcClearBit(integerPart *, unsigned int bit)
Clear the given bit of a bignum. Zero-based.
unsigned getActiveBits() const
Compute the number of active bits in the value.
hash_code hash_value(const APFloat &Arg)
See friend declarations above.
static unsigned int semanticsPrecision(const fltSemantics &)
double convertToDouble() const
static APFloat getInf(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Infinity.
unsigned int convertToHexString(char *dst, unsigned int hexDigits, bool upperCase, roundingMode) const
Write out a hexadecimal representation of the floating point value to DST, which must be of sufficien...
opStatus mod(const APFloat &, roundingMode)
C fmod, or llvm frem.
static integerPart tcDecrement(integerPart *, unsigned int)
Decrement a bignum in-place. Return the borrow flag.
opStatus convertFromAPInt(const APInt &, bool, roundingMode)
static unsigned int partAsHex(char *dst, integerPart part, unsigned int count, const char *hexDigitChars)
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
static void tcSet(integerPart *, integerPart, unsigned int)
Sets the least significant part of a bignum to the input value, and zeroes out higher parts...
static APFloat getSmallestNormalized(const fltSemantics &Sem, bool Negative=false)
Returns the smallest (by magnitude) normalized finite number in the given semantics.
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
const char * firstSigDigit
APInt LLVM_ATTRIBUTE_UNUSED_RESULT trunc(unsigned width) const
Truncate to new width.
cmpResult compare(const APFloat &) const
IEEE comparison with another floating point number (NaNs compare unordered, 0==-0).
static integerPart ulpsFromBoundary(const integerPart *parts, unsigned int bits, bool isNearest)
const unsigned int integerPartWidth
const unsigned int maxPowerOfFiveExponent
opStatus fusedMultiplyAdd(const APFloat &, const APFloat &, roundingMode)
This file declares a class to represent arbitrary precision floating point values and provide a varie...
static unsigned int tcFullMultiply(integerPart *, const integerPart *, const integerPart *, unsigned, unsigned)
DST = LHS * RHS, where DST has width the sum of the widths of the operands.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
unsigned getBitWidth() const
Return the number of bits in the APInt.
opStatus convert(const fltSemantics &, roundingMode, bool *)
APFloat::convert - convert a value of one floating point type to another.
APFloat::ExponentType minExponent
APFloat scalbn(APFloat X, int Exp)
const unsigned int maxPrecision
static integerPart tcAdd(integerPart *, const integerPart *, integerPart carry, unsigned)
DST += RHS + CARRY where CARRY is zero or one. Returns the carry flag.
static unsigned int powerOf5(integerPart *dst, unsigned int power)
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
uint64_t NextPowerOf2(uint64_t A)
NextPowerOf2 - Returns the next power of two (in 64-bits) that is strictly greater than A...
iterator erase(iterator I)
static int tcCompare(const integerPart *, const integerPart *, unsigned int)
Comparison (unsigned) of two bignums.
static const fltSemantics IEEEhalf
bool needsCleanup() const
Returns whether this instance allocated memory.
static void tcSetBit(integerPart *, unsigned int bit)
Set the given bit of a bignum. Zero-based.
unsigned countTrailingZeros() const
Count the number of trailing zero bits.
opStatus convertFromSignExtendedInteger(const integerPart *, unsigned int, bool, roundingMode)
static const fltSemantics PPCDoubleDouble
roundingMode
IEEE-754R 4.3: Rounding-direction attributes.
static APInt LLVM_ATTRIBUTE_UNUSED_RESULT doubleToBits(double V)
Converts a double to APInt bits.
lostFraction
Enum that represents what fraction of the LSB truncated bits of an fp number represent.
bool isNegative() const
IEEE-754R isSignMinus: Returns true if and only if the current value is negative. ...
opStatus add(const APFloat &, roundingMode)
bool isDenormal() const
IEEE-754R isSubnormal(): Returns true if and only if the float is a denormal.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
static StringRef::iterator skipLeadingZeroesAndAnyDot(StringRef::iterator begin, StringRef::iterator end, StringRef::iterator *dot)
opStatus multiply(const APFloat &, roundingMode)
static APFloat getAllOnesValue(unsigned BitWidth, bool isIEEE=false)
Returns a float which is bitcasted from an all one value int.
static const char infinityL[]
Class for arbitrary precision integers.
static const char hexDigitsLower[]
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
APInt bitcastToAPInt() const
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
static APFloat getLargest(const fltSemantics &Sem, bool Negative=false)
Returns the largest finite number in the given semantics.
An opaque object representing a hash code.
bool equals(StringRef RHS) const
equals - Check for string equality, this is more efficient than compare() when the relative ordering ...
static unsigned int tcMSB(const integerPart *parts, unsigned int n)
const char * lastSigDigit
double bitsToDouble() const
Converts APInt bits to a double.
static const char hexDigitsUpper[]
static const char infinityU[]
void toString(SmallVectorImpl< char > &Str, unsigned FormatPrecision=0, unsigned FormatMaxPadding=3) const
Converts this value into a decimal string.
static const fltSemantics IEEEsingle
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
APInt LLVM_ATTRIBUTE_UNUSED_RESULT udiv(const APInt &RHS) const
Unsigned division operation.
opStatus roundToIntegral(roundingMode)
static APInt LLVM_ATTRIBUTE_UNUSED_RESULT floatToBits(float V)
Converts a float to APInt bits.
static char * writeUnsignedDecimal(char *dst, unsigned int n)
float convertToFloat() const
static int readExponent(StringRef::iterator begin, StringRef::iterator end)
bool isSmallest() const
Returns true if and only if the number has the smallest possible non-zero magnitude in the current se...
const unsigned int maxExponent
static integerPart tcSubtract(integerPart *, const integerPart *, integerPart carry, unsigned)
DST -= RHS + CARRY where CARRY is zero or one. Returns the carry flag.
static lostFraction combineLostFractions(lostFraction moreSignificant, lostFraction lessSignificant)
static unsigned int partCountForBits(unsigned int bits)
APFloat::ExponentType maxExponent
static unsigned hexDigitValue(char C)
Interpret the given character C as a hexadecimal digit and return its value.
static void udivrem(const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder)
Dual division/remainder interface.
bool isZero() const
Returns true if and only if the float is plus or minus zero.
static unsigned getSizeInBits(const fltSemantics &Sem)
Returns the size of the floating point number (in bits) in the given semantics.
bool isLargest() const
Returns true if and only if the number has the largest possible finite magnitude in the current seman...
bool isInfinity() const
IEEE-754R isInfinite(): Returns true if and only if the float is infinity.
StringRef - Represent a constant reference to a string, i.e.
#define PackCategoriesIntoKey(_lhs, _rhs)
A macro used to combine two fcCategory enums into one key which can be used in a switch statement to ...
APInt LLVM_ATTRIBUTE_UNUSED_RESULT zext(unsigned width) const
Zero extend to a new width.
opStatus next(bool nextDown)
IEEE-754R 5.3.1: nextUp/nextDown.
opStatus remainder(const APFloat &)
IEEE remainder.
std::error_code status(const Twine &path, file_status &result)
Get file status as if by POSIX stat().
cmpResult
IEEE-754R 5.11: Floating Point Comparison Relations.
bool getExactInverse(APFloat *inv) const
If this value has an exact multiplicative inverse, store it in inv and return true.
static void tcShiftRight(integerPart *, unsigned int parts, unsigned int count)
Shift a bignum right COUNT bits.
const fltSemantics & getSemantics() const
opStatus subtract(const APFloat &, roundingMode)
float bitsToFloat() const
Converts APInt bits to a double.
bool empty() const
empty - Check if the string is empty.
unsigned getNumWords() const
Get the number of words.