MCPcopy Create free account
hub / github.com/ablab/spades / convertToInteger

Method convertToInteger

ext/src/llvm/APFloat.cpp:2373–2401  ·  view source on GitHub ↗

Same as convertToSignExtendedInteger, except we provide deterministic values in case of an invalid operation exception, namely zero for NaNs and the minimal or maximal value respectively for underflow or overflow. The *isExact output tells whether the result is exact, in the sense that converting it back to the original floating point type produces the original value. This is al

Source from the content-addressed store, hash-verified

2371 except for negative zeroes.
2372*/
2373IEEEFloat::opStatus
2374IEEEFloat::convertToInteger(MutableArrayRef<integerPart> parts,
2375 unsigned int width, bool isSigned,
2376 roundingMode rounding_mode, bool *isExact) const {
2377 opStatus fs;
2378
2379 fs = convertToSignExtendedInteger(parts, width, isSigned, rounding_mode,
2380 isExact);
2381
2382 if (fs == opInvalidOp) {
2383 unsigned int bits, dstPartsCount;
2384
2385 dstPartsCount = partCountForBits(width);
2386 assert(dstPartsCount <= parts.size() && "Integer too big");
2387
2388 if (category == fcNaN)
2389 bits = 0;
2390 else if (sign)
2391 bits = isSigned;
2392 else
2393 bits = width - isSigned;
2394
2395 APInt::tcSetLeastSignificantBits(parts.data(), dstPartsCount, bits);
2396 if (sign && isSigned)
2397 APInt::tcShiftLeft(parts.data(), dstPartsCount, width - 1);
2398 }
2399
2400 return fs;
2401}
2402
2403/* Convert an unsigned integer SRC to a floating point number,
2404 rounding according to ROUNDING_MODE. The sign of the floating

Callers

nothing calls this directly

Calls 6

partCountForBitsFunction · 0.85
assertClass · 0.85
APFloatClass · 0.85
APIntFunction · 0.50
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected