LLVM 17.0.0git
|
#include "llvm/ADT/APFloat.h"
Public Member Functions | |
bool | needsCleanup () const |
Returns whether this instance allocated memory. | |
bool | operator== (const IEEEFloat &) const =delete |
The definition of equality is not straightforward for floating point, so we won't use operator==. | |
cmpResult | compare (const IEEEFloat &) const |
IEEE comparison with another floating point number (NaNs compare unordered, 0==-0). | |
bool | bitwiseIsEqual (const IEEEFloat &) const |
Bitwise comparison for equality (QNaNs compare equal, 0!=-0). | |
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 sufficient size, in the C99 form [-]0xh.hhhhp[+-]d. | |
IEEEFloat & | operator= (const IEEEFloat &) |
IEEEFloat & | operator= (IEEEFloat &&) |
void | toString (SmallVectorImpl< char > &Str, unsigned FormatPrecision=0, unsigned FormatMaxPadding=3, bool TruncateZero=true) const |
Converts this value into a decimal string. | |
bool | getExactInverse (APFloat *inv) const |
If this value has an exact multiplicative inverse, store it in inv and return true. | |
cmpResult | compareAbsoluteValue (const IEEEFloat &) const |
Constructors | |
IEEEFloat (const fltSemantics &) | |
IEEEFloat (const fltSemantics &, integerPart) | |
IEEEFloat (const fltSemantics &, uninitializedTag) | |
IEEEFloat (const fltSemantics &, const APInt &) | |
IEEEFloat (double d) | |
IEEEFloat (float f) | |
IEEEFloat (const IEEEFloat &) | |
IEEEFloat (IEEEFloat &&) | |
~IEEEFloat () | |
Arithmetic | |
opStatus | add (const IEEEFloat &, roundingMode) |
opStatus | subtract (const IEEEFloat &, roundingMode) |
opStatus | multiply (const IEEEFloat &, roundingMode) |
opStatus | divide (const IEEEFloat &, roundingMode) |
opStatus | remainder (const IEEEFloat &) |
IEEE remainder. | |
opStatus | mod (const IEEEFloat &) |
C fmod, or llvm frem. | |
opStatus | fusedMultiplyAdd (const IEEEFloat &, const IEEEFloat &, roundingMode) |
opStatus | roundToIntegral (roundingMode) |
opStatus | next (bool nextDown) |
IEEE-754R 5.3.1: nextUp/nextDown. | |
Sign operations. | |
void | changeSign () |
Conversions | |
opStatus | convert (const fltSemantics &, roundingMode, bool *) |
IEEEFloat::convert - convert a value of one floating point type to another. | |
opStatus | convertToInteger (MutableArrayRef< integerPart >, unsigned int, bool, roundingMode, bool *) const |
opStatus | convertFromAPInt (const APInt &, bool, roundingMode) |
opStatus | convertFromSignExtendedInteger (const integerPart *, unsigned int, bool, roundingMode) |
opStatus | convertFromZeroExtendedInteger (const integerPart *, unsigned int, bool, roundingMode) |
Expected< opStatus > | convertFromString (StringRef, roundingMode) |
APInt | bitcastToAPInt () const |
double | convertToDouble () const |
float | convertToFloat () const |
IEEE-754R 5.7.2 General operations. | |
bool | isNegative () const |
IEEE-754R isSignMinus: Returns true if and only if the current value is negative. | |
bool | isNormal () const |
IEEE-754R isNormal: Returns true if and only if the current value is normal. | |
bool | isFinite () const |
Returns true if and only if the current value is zero, subnormal, or normal. | |
bool | isZero () const |
Returns true if and only if the float is plus or minus zero. | |
bool | isDenormal () const |
IEEE-754R isSubnormal(): Returns true if and only if the float is a denormal. | |
bool | isInfinity () const |
IEEE-754R isInfinite(): Returns true if and only if the float is infinity. | |
bool | isNaN () const |
Returns true if and only if the float is a quiet or signaling NaN. | |
bool | isSignaling () const |
Returns true if and only if the float is a signaling NaN. | |
Special value setters. | |
void | makeLargest (bool Neg=false) |
Make this number the largest magnitude normal number in the given semantics. | |
void | makeSmallest (bool Neg=false) |
Make this number the smallest magnitude denormal number in the given semantics. | |
void | makeNaN (bool SNaN=false, bool Neg=false, const APInt *fill=nullptr) |
void | makeInf (bool Neg=false) |
void | makeZero (bool Neg=false) |
void | makeQuiet () |
void | makeSmallestNormalized (bool Negative=false) |
Returns the smallest (by magnitude) normalized finite number in the given semantics. | |
Friends | |
hash_code | hash_value (const IEEEFloat &Arg) |
Overload to compute a hash code for an APFloat value. | |
int | ilogb (const IEEEFloat &Arg) |
Returns the exponent of the internal representation of the APFloat. | |
IEEEFloat | scalbn (IEEEFloat X, int Exp, roundingMode) |
Returns: X * 2^Exp for integral exponents. | |
IEEEFloat | frexp (const IEEEFloat &X, int &Exp, roundingMode) |
Simple Queries | |
fltCategory | getCategory () const |
const fltSemantics & | getSemantics () const |
bool | isNonZero () const |
bool | isFiniteNonZero () const |
bool | isPosZero () const |
bool | isNegZero () const |
bool | isSmallest () const |
Returns true if and only if the number has the smallest possible non-zero magnitude in the current semantics. | |
bool | isSmallestNormalized () const |
Returns true if this is the smallest (by magnitude) normalized finite number in the given semantics. | |
bool | isLargest () const |
Returns true if and only if the number has the largest possible finite magnitude in the current semantics. | |
bool | isInteger () const |
Returns true if and only if the number is an exact integer. | |
llvm::detail::IEEEFloat::IEEEFloat | ( | const fltSemantics & | ourSemantics | ) |
Definition at line 1111 of file APFloat.cpp.
References makeZero().
llvm::detail::IEEEFloat::IEEEFloat | ( | const fltSemantics & | ourSemantics, |
integerPart | value | ||
) |
Definition at line 1101 of file APFloat.cpp.
References llvm::APFloatBase::fcNormal, llvm::lfExactlyZero, llvm::fltSemantics::precision, llvm::APFloatBase::rmNearestTiesToEven, and value.
llvm::detail::IEEEFloat::IEEEFloat | ( | const fltSemantics & | ourSemantics, |
uninitializedTag | tag | ||
) |
Definition at line 1118 of file APFloat.cpp.
llvm::detail::IEEEFloat::IEEEFloat | ( | const fltSemantics & | Sem, |
const APInt & | API | ||
) |
Definition at line 4237 of file APFloat.cpp.
|
explicit |
Definition at line 4245 of file APFloat.cpp.
References llvm::APInt::doubleToBits(), and llvm::semIEEEdouble.
|
explicit |
Definition at line 4241 of file APFloat.cpp.
References llvm::APInt::floatToBits(), and llvm::semIEEEsingle.
Definition at line 1121 of file APFloat.cpp.
llvm::detail::IEEEFloat::IEEEFloat | ( | IEEEFloat && | rhs | ) |
Definition at line 1126 of file APFloat.cpp.
llvm::detail::IEEEFloat::~IEEEFloat | ( | ) |
Definition at line 1130 of file APFloat.cpp.
IEEEFloat::opStatus llvm::detail::IEEEFloat::add | ( | const IEEEFloat & | rhs, |
roundingMode | rounding_mode | ||
) |
Definition at line 2020 of file APFloat.cpp.
Referenced by remainder(), and roundToIntegral().
APInt llvm::detail::IEEEFloat::bitcastToAPInt | ( | ) | const |
Definition at line 3758 of file APFloat.cpp.
References assert(), llvm::semBFloat, llvm::semFloat8E4M3B11FNUZ, llvm::semFloat8E4M3FN, llvm::semFloat8E4M3FNUZ, llvm::semFloat8E5M2, llvm::semFloat8E5M2FNUZ, llvm::semIEEEdouble, llvm::semIEEEhalf, llvm::semIEEEquad, llvm::semIEEEsingle, llvm::semPPCDoubleDoubleLegacy, and llvm::semX87DoubleExtended.
Referenced by convertToDouble(), and convertToFloat().
Bitwise comparison for equality (QNaNs compare equal, 0!=-0).
Definition at line 1084 of file APFloat.cpp.
References llvm::APFloatBase::fcInfinity, llvm::APFloatBase::fcZero, and isFiniteNonZero().
void llvm::detail::IEEEFloat::changeSign | ( | ) |
Definition at line 1976 of file APFloat.cpp.
References isNaN(), isZero(), llvm::fltSemantics::nanEncoding, and llvm::NegativeZero.
Referenced by next(), and roundToIntegral().
IEEEFloat::cmpResult llvm::detail::IEEEFloat::compare | ( | const IEEEFloat & | rhs | ) | const |
IEEE comparison with another floating point number (NaNs compare unordered, 0==-0).
Definition at line 2342 of file APFloat.cpp.
References assert(), llvm::APFloatBase::cmpEqual, llvm::APFloatBase::cmpGreaterThan, llvm::APFloatBase::cmpLessThan, llvm::APFloatBase::cmpUnordered, compareAbsoluteValue(), llvm::APFloatBase::fcInfinity, llvm::APFloatBase::fcNaN, llvm::APFloatBase::fcNormal, llvm::APFloatBase::fcZero, llvm_unreachable, and PackCategoriesIntoKey.
Referenced by compareAbsoluteValue(), isInteger(), and remainder().
IEEEFloat::cmpResult llvm::detail::IEEEFloat::compareAbsoluteValue | ( | const IEEEFloat & | rhs | ) | const |
Definition at line 1444 of file APFloat.cpp.
References assert(), llvm::APFloatBase::cmpEqual, llvm::APFloatBase::cmpGreaterThan, llvm::APFloatBase::cmpLessThan, compare(), isFiniteNonZero(), and llvm::APInt::tcCompare().
IEEEFloat::opStatus llvm::detail::IEEEFloat::convert | ( | const fltSemantics & | toSemantics, |
roundingMode | rounding_mode, | ||
bool * | losesInfo | ||
) |
IEEEFloat::convert - convert a value of one floating point type to another.
The return value corresponds to the IEEE754 exceptions. *losesInfo records whether the transformation lost information, i.e. whether converting the result back to the original type will produce the original value (this is almost the same as return value==fsOK, but there are edge cases where this is not so).
Definition at line 2419 of file APFloat.cpp.
References llvm::APFloatBase::fcInfinity, llvm::APFloatBase::fcNaN, llvm::APFloatBase::fcZero, isFiniteNonZero(), isSignaling(), llvm::lfExactlyZero, makeNaN(), makeQuiet(), llvm::fltSemantics::minExponent, llvm::fltSemantics::nanEncoding, llvm::NanOnly, llvm::NegativeZero, llvm::fltSemantics::nonFiniteBehavior, llvm::APFloatBase::opInexact, llvm::APFloatBase::opInvalidOp, llvm::APFloatBase::opOK, llvm::partCountForBits(), llvm::fltSemantics::precision, llvm::semX87DoubleExtended, llvm::shiftRight(), llvm::APInt::tcAssign(), llvm::APInt::tcSet(), llvm::APInt::tcSetBit(), and llvm::APInt::tcShiftLeft().
Referenced by llvm::APFloat::convert(), and remainder().
IEEEFloat::opStatus llvm::detail::IEEEFloat::convertFromAPInt | ( | const APInt & | Val, |
bool | isSigned, | ||
roundingMode | rounding_mode | ||
) |
Definition at line 2739 of file APFloat.cpp.
References llvm::APInt::getNumWords(), llvm::APInt::getRawData(), llvm::APInt::isNegative(), and isSigned().
Referenced by roundToIntegral().
IEEEFloat::opStatus llvm::detail::IEEEFloat::convertFromSignExtendedInteger | ( | const integerPart * | src, |
unsigned int | srcCount, | ||
bool | isSigned, | ||
roundingMode | rounding_mode | ||
) |
Definition at line 2757 of file APFloat.cpp.
References llvm::copy(), llvm::APFloatBase::integerPartWidth, isSigned(), llvm::APInt::tcAssign(), llvm::APInt::tcExtractBit(), and llvm::APInt::tcNegate().
Expected< IEEEFloat::opStatus > llvm::detail::IEEEFloat::convertFromString | ( | StringRef | str, |
roundingMode | rounding_mode | ||
) |
Definition at line 3171 of file APFloat.cpp.
References llvm::StringRef::begin(), llvm::createError(), llvm::StringRef::empty(), llvm::APFloatBase::opOK, and llvm::StringRef::size().
IEEEFloat::opStatus llvm::detail::IEEEFloat::convertFromZeroExtendedInteger | ( | const integerPart * | parts, |
unsigned int | width, | ||
bool | isSigned, | ||
roundingMode | rounding_mode | ||
) |
Definition at line 2783 of file APFloat.cpp.
References llvm::APInt::getRawData(), isSigned(), llvm::partCountForBits(), and llvm::APInt::tcExtractBit().
double llvm::detail::IEEEFloat::convertToDouble | ( | ) | const |
Definition at line 3804 of file APFloat.cpp.
References assert(), bitcastToAPInt(), llvm::APInt::bitsToDouble(), and llvm::semIEEEdouble.
Referenced by llvm::APFloat::convertToDouble().
float llvm::detail::IEEEFloat::convertToFloat | ( | ) | const |
Definition at line 3797 of file APFloat.cpp.
References assert(), bitcastToAPInt(), llvm::APInt::bitsToFloat(), and llvm::semIEEEsingle.
Referenced by llvm::APFloat::convertToFloat().
unsigned int llvm::detail::IEEEFloat::convertToHexString | ( | char * | dst, |
unsigned int | hexDigits, | ||
bool | upperCase, | ||
roundingMode | rounding_mode | ||
) | const |
Write out a hexadecimal representation of the floating point value to DST, which must be of sufficient size, in the C99 form [-]0xh.hhhhp[+-]d.
Return the number of characters written, excluding the terminating NUL.
Definition at line 3224 of file APFloat.cpp.
References llvm::APFloatBase::fcInfinity, llvm::APFloatBase::fcNaN, llvm::APFloatBase::fcNormal, llvm::APFloatBase::fcZero, llvm::infinityL, llvm::infinityU, llvm::NaNL, and llvm::NaNU.
IEEEFloat::opStatus llvm::detail::IEEEFloat::convertToInteger | ( | MutableArrayRef< integerPart > | parts, |
unsigned int | width, | ||
bool | isSigned, | ||
roundingMode | rounding_mode, | ||
bool * | isExact | ||
) | const |
Definition at line 2679 of file APFloat.cpp.
References assert(), bits, llvm::MutableArrayRef< T >::data(), llvm::APFloatBase::fcNaN, isSigned(), llvm::APFloatBase::opInvalidOp, llvm::partCountForBits(), llvm::ArrayRef< T >::size(), llvm::detail::tcSetLeastSignificantBits(), and llvm::APInt::tcShiftLeft().
IEEEFloat::opStatus llvm::detail::IEEEFloat::divide | ( | const IEEEFloat & | rhs, |
roundingMode | rounding_mode | ||
) |
Definition at line 2052 of file APFloat.cpp.
References isFiniteNonZero(), isZero(), llvm::lfExactlyZero, llvm::fltSemantics::nanEncoding, llvm::NegativeZero, and llvm::APFloatBase::opInexact.
Referenced by getExactInverse().
IEEEFloat::opStatus llvm::detail::IEEEFloat::fusedMultiplyAdd | ( | const IEEEFloat & | multiplicand, |
const IEEEFloat & | addend, | ||
roundingMode | rounding_mode | ||
) |
Definition at line 2209 of file APFloat.cpp.
References llvm::APFloatBase::fcZero, isFinite(), isFiniteNonZero(), llvm::lfExactlyZero, llvm::fltSemantics::nanEncoding, llvm::NegativeZero, llvm::APFloatBase::opInexact, llvm::APFloatBase::opOK, llvm::APFloatBase::opUnderflow, and llvm::APFloatBase::rmTowardNegative.
|
inline |
Definition at line 411 of file APFloat.h.
Referenced by llvm::APFloat::getCategory(), and isSmallestNormalized().
If this value has an exact multiplicative inverse, store it in inv and return true.
Definition at line 4554 of file APFloat.cpp.
References assert(), divide(), isDenormal(), isFiniteNonZero(), llvm::APFloatBase::opOK, llvm::fltSemantics::precision, and llvm::APFloatBase::rmNearestTiesToEven.
|
inline |
bool llvm::detail::IEEEFloat::isDenormal | ( | ) | const |
IEEE-754R isSubnormal(): Returns true if and only if the float is a denormal.
Definition at line 954 of file APFloat.cpp.
References isFiniteNonZero(), llvm::fltSemantics::minExponent, llvm::fltSemantics::precision, and llvm::APInt::tcExtractBit().
Referenced by getExactInverse(), isNormal(), and next().
|
inline |
Returns true if and only if the current value is zero, subnormal, or normal.
This means that the value is not infinite or NaN.
Definition at line 388 of file APFloat.h.
References isInfinity(), and isNaN().
Referenced by fusedMultiplyAdd(), isFiniteNonZero(), and isInteger().
|
inline |
Definition at line 414 of file APFloat.h.
References isFinite(), and isZero().
Referenced by bitwiseIsEqual(), compareAbsoluteValue(), convert(), divide(), fusedMultiplyAdd(), getExactInverse(), isDenormal(), isLargest(), isNormal(), isSmallest(), mod(), and multiply().
|
inline |
IEEE-754R isInfinite(): Returns true if and only if the float is infinity.
Definition at line 398 of file APFloat.h.
References llvm::APFloatBase::fcInfinity.
Referenced by isFinite(), and roundToIntegral().
bool llvm::detail::IEEEFloat::isInteger | ( | ) | const |
Returns true if and only if the number is an exact integer.
Definition at line 1076 of file APFloat.cpp.
References llvm::APFloatBase::cmpEqual, compare(), isFinite(), llvm::APFloatBase::rmTowardZero, and llvm::truncated.
bool llvm::detail::IEEEFloat::isLargest | ( | ) | const |
Returns true if and only if the number has the largest possible finite magnitude in the current semantics.
Definition at line 1060 of file APFloat.cpp.
References llvm::AllOnes, isFiniteNonZero(), llvm::fltSemantics::maxExponent, llvm::fltSemantics::nanEncoding, llvm::NanOnly, and llvm::fltSemantics::nonFiniteBehavior.
Referenced by next().
|
inline |
Returns true if and only if the float is a quiet or signaling NaN.
Definition at line 401 of file APFloat.h.
References llvm::APFloatBase::fcNaN.
Referenced by changeSign(), isFinite(), isSignaling(), makeQuiet(), and roundToIntegral().
|
inline |
IEEE-754R isSignMinus: Returns true if and only if the current value is negative.
This applies to zeros and NaNs as well.
Definition at line 376 of file APFloat.h.
Referenced by llvm::APFloat::isNegative(), isNegZero(), isPosZero(), next(), roundToIntegral(), and toString().
|
inline |
Definition at line 416 of file APFloat.h.
References isNegative(), and isZero().
|
inline |
Definition at line 413 of file APFloat.h.
References llvm::APFloatBase::fcZero.
|
inline |
IEEE-754R isNormal: Returns true if and only if the current value is normal.
This implies that the current value of the float is not zero, subnormal, infinite, or NaN following the definition of normality from IEEE-754R.
Definition at line 382 of file APFloat.h.
References isDenormal(), and isFiniteNonZero().
|
inline |
Definition at line 415 of file APFloat.h.
References isNegative(), and isZero().
bool llvm::detail::IEEEFloat::isSignaling | ( | ) | const |
Returns true if and only if the float is a signaling NaN.
Definition at line 4583 of file APFloat.cpp.
References isNaN(), llvm::NanOnly, llvm::fltSemantics::nonFiniteBehavior, llvm::fltSemantics::precision, and llvm::APInt::tcExtractBit().
Referenced by convert(), llvm::APFloat::isSignaling(), next(), and roundToIntegral().
bool llvm::detail::IEEEFloat::isSmallest | ( | ) | const |
Returns true if and only if the number has the smallest possible non-zero magnitude in the current semantics.
Definition at line 960 of file APFloat.cpp.
References isFiniteNonZero(), and llvm::fltSemantics::minExponent.
Referenced by next().
bool llvm::detail::IEEEFloat::isSmallestNormalized | ( | ) | const |
Returns true if this is the smallest (by magnitude) normalized finite number in the given semantics.
Definition at line 968 of file APFloat.cpp.
References llvm::APFloatBase::fcNormal, getCategory(), and llvm::fltSemantics::minExponent.
|
inline |
Returns true if and only if the float is plus or minus zero.
Definition at line 391 of file APFloat.h.
References llvm::APFloatBase::fcZero.
Referenced by changeSign(), divide(), isFiniteNonZero(), isNegZero(), isPosZero(), mod(), multiply(), remainder(), and roundToIntegral().
void llvm::detail::IEEEFloat::makeInf | ( | bool | Neg = false | ) |
Definition at line 4739 of file APFloat.cpp.
References llvm::APFloatBase::fcInfinity, makeNaN(), llvm::NanOnly, llvm::fltSemantics::nonFiniteBehavior, and llvm::APInt::tcSet().
void llvm::detail::IEEEFloat::makeLargest | ( | bool | Neg = false | ) |
Make this number the largest magnitude normal number in the given semantics.
Definition at line 4184 of file APFloat.cpp.
References llvm::AllOnes, llvm::APFloatBase::fcNormal, llvm::APFloatBase::integerPartWidth, llvm::fltSemantics::maxExponent, llvm::fltSemantics::nanEncoding, llvm::NanOnly, llvm::fltSemantics::nonFiniteBehavior, and llvm::fltSemantics::precision.
Referenced by next().
void llvm::detail::IEEEFloat::makeNaN | ( | bool | SNaN = false , |
bool | Neg = false , |
||
const APInt * | fill = nullptr |
||
) |
Definition at line 865 of file APFloat.cpp.
References llvm::APFloatBase::fcNaN, llvm::APInt::getAllOnes(), llvm::APInt::getNumWords(), llvm::APInt::getRawData(), llvm::APInt::getZero(), llvm::fltSemantics::nanEncoding, llvm::NanOnly, llvm::NegativeZero, llvm::fltSemantics::nonFiniteBehavior, llvm::fltSemantics::precision, llvm::semX87DoubleExtended, llvm::APInt::tcAssign(), llvm::APInt::tcClearBit(), llvm::APInt::tcIsZero(), llvm::APInt::tcSet(), and llvm::APInt::tcSetBit().
void llvm::detail::IEEEFloat::makeQuiet | ( | ) |
Definition at line 4762 of file APFloat.cpp.
References assert(), isNaN(), llvm::NanOnly, llvm::fltSemantics::nonFiniteBehavior, llvm::fltSemantics::precision, and llvm::APInt::tcSetBit().
Referenced by convert(), and roundToIntegral().
void llvm::detail::IEEEFloat::makeSmallest | ( | bool | Neg = false | ) |
Make this number the smallest magnitude denormal number in the given semantics.
Definition at line 4213 of file APFloat.cpp.
References llvm::APFloatBase::fcNormal, llvm::fltSemantics::minExponent, and llvm::APInt::tcSet().
Referenced by next().
void llvm::detail::IEEEFloat::makeSmallestNormalized | ( | bool | Negative = false | ) |
Returns the smallest (by magnitude) normalized finite number in the given semantics.
Negative | - True iff the number should be negative |
Definition at line 4224 of file APFloat.cpp.
References llvm::APFloatBase::fcNormal, llvm::fltSemantics::minExponent, llvm::fltSemantics::precision, and llvm::APInt::tcSetBit().
void llvm::detail::IEEEFloat::makeZero | ( | bool | Neg = false | ) |
Definition at line 4751 of file APFloat.cpp.
References llvm::APFloatBase::fcZero, llvm::fltSemantics::nanEncoding, llvm::NegativeZero, and llvm::APInt::tcSet().
Referenced by IEEEFloat().
IEEEFloat::opStatus llvm::detail::IEEEFloat::mod | ( | const IEEEFloat & | rhs | ) |
C fmod, or llvm frem.
Definition at line 2182 of file APFloat.cpp.
References assert(), llvm::APFloatBase::cmpLessThan, compareAbsoluteValue(), ilogb, isFiniteNonZero(), isZero(), llvm::fltSemantics::nanEncoding, llvm::NegativeZero, llvm::APFloatBase::opOK, llvm::APFloatBase::rmNearestTiesToEven, scalbn, and subtract().
Referenced by remainder().
IEEEFloat::opStatus llvm::detail::IEEEFloat::multiply | ( | const IEEEFloat & | rhs, |
roundingMode | rounding_mode | ||
) |
Definition at line 2032 of file APFloat.cpp.
References isFiniteNonZero(), isZero(), llvm::lfExactlyZero, llvm::fltSemantics::nanEncoding, llvm::NegativeZero, and llvm::APFloatBase::opInexact.
|
inline |
IEEEFloat::opStatus llvm::detail::IEEEFloat::next | ( | bool | nextDown | ) |
IEEE-754R 5.3.1: nextUp/nextDown.
IEEE-754R 2008 5.3.1: nextUp/nextDown.
NOTE since nextDown(x) = -nextUp(-x), we only implement nextUp with appropriate sign switching before/after the computation.
Definition at line 4598 of file APFloat.cpp.
References assert(), changeSign(), llvm::APFloatBase::fcInfinity, llvm::APFloatBase::fcNaN, llvm::APFloatBase::fcNormal, llvm::APFloatBase::fcZero, isDenormal(), isLargest(), isNegative(), isSignaling(), isSmallest(), makeLargest(), makeNaN(), makeSmallest(), llvm::fltSemantics::maxExponent, llvm::fltSemantics::minExponent, llvm::fltSemantics::nanEncoding, llvm::NanOnly, llvm::NegativeZero, llvm::fltSemantics::nonFiniteBehavior, llvm::APFloatBase::opInvalidOp, llvm::APFloatBase::opOK, llvm::fltSemantics::precision, llvm::APInt::tcDecrement(), llvm::APInt::tcSet(), and llvm::APInt::tcSetBit().
Definition at line 929 of file APFloat.cpp.
Definition at line 941 of file APFloat.cpp.
References llvm::semBogus.
The definition of equality is not straightforward for floating point, so we won't use operator==.
Use one of the following, or write whatever it is you really mean.
IEEEFloat::opStatus llvm::detail::IEEEFloat::remainder | ( | const IEEEFloat & | rhs | ) |
IEEE remainder.
Definition at line 2072 of file APFloat.cpp.
References add(), assert(), llvm::APFloatBase::cmpEqual, llvm::APFloatBase::cmpGreaterThan, compare(), convert(), isZero(), llvm::fltSemantics::maxExponent, llvm::fltSemantics::minExponent, mod(), llvm::fltSemantics::nanEncoding, llvm::NegativeZero, llvm::APFloatBase::opDivByZero, llvm::APFloatBase::opOK, P, llvm::fltSemantics::precision, llvm::APFloatBase::rmNearestTiesToEven, and subtract().
IEEEFloat::opStatus llvm::detail::IEEEFloat::roundToIntegral | ( | roundingMode | rounding_mode | ) |
Definition at line 2255 of file APFloat.cpp.
References add(), assert(), changeSign(), convertFromAPInt(), isInfinity(), isNaN(), isNegative(), isSignaling(), isZero(), makeQuiet(), llvm::NextPowerOf2(), llvm::APFloatBase::opInvalidOp, llvm::APFloatBase::opOK, llvm::APFloatBase::rmNearestTiesToEven, llvm::APFloatBase::semanticsPrecision(), and subtract().
IEEEFloat::opStatus llvm::detail::IEEEFloat::subtract | ( | const IEEEFloat & | rhs, |
roundingMode | rounding_mode | ||
) |
Definition at line 2026 of file APFloat.cpp.
Referenced by mod(), remainder(), and roundToIntegral().
void llvm::detail::IEEEFloat::toString | ( | SmallVectorImpl< char > & | Str, |
unsigned | FormatPrecision = 0 , |
||
unsigned | FormatMaxPadding = 3 , |
||
bool | TruncateZero = true |
||
) | const |
Converts this value into a decimal string.
FormatPrecision | The maximum number of digits of precision to output. If there are fewer digits available, zero padding will not be used unless the value is integral and small enough to be expressed in FormatPrecision digits. 0 means to use the natural precision of the number. |
FormatMaxPadding | The maximum number of zeros to consider inserting before falling back to scientific notation. 0 means to always use scientific notation. |
TruncateZero | Indicate whether to remove the trailing zero in fraction part or not. Also setting this parameter to false forcing producing of output more similar to default printf behavior. Specifically the lower e is used as exponent delimiter and exponent always contains no less than two digits. |
Number Precision MaxPadding Result
1.01E+4 5 2 10100 1.01E+4 4 2 1.01E+4 1.01E+4 5 1 1.01E+4 1.01E-2 5 2 0.0101 1.01E-2 4 2 0.0101 1.01E-2 4 1 1.01E-2
Definition at line 4333 of file APFloat.cpp.
References assert(), llvm::APInt::countr_zero(), E, llvm::SmallVectorBase< Size_T >::empty(), llvm::APFloatBase::fcInfinity, llvm::APFloatBase::fcNaN, llvm::APFloatBase::fcNormal, llvm::APFloatBase::fcZero, llvm::APInt::getBitWidth(), llvm::APInt::getZExtValue(), I, isNegative(), llvm::APInt::lshrInPlace(), llvm::partCountForBits(), llvm::fltSemantics::precision, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::SmallVectorBase< Size_T >::size(), llvm::APInt::udivrem(), and llvm::APInt::zext().
|
friend |
Overload to compute a hash code for an APFloat value.
Note that the use of hash codes for floating point values is in general frought with peril. Equality is hard to define for these values. For example, should negative and positive zero hash to different codes? Are they equal or not? This hash value implementation specifically emphasizes producing different codes for different inputs in order to be used in canonicalization and memoization. As such, equality is bitwiseIsEqual, and 0 != -0.
Definition at line 3373 of file APFloat.cpp.
Returns the exponent of the internal representation of the APFloat.
Because the radix of APFloat is 2, this is equivalent to floor(log2(x)). For special APFloat values, this returns special error codes:
NaN -> IEK_NaN
0 -> IEK_Zero
Inf -> IEK_Inf
Definition at line 4768 of file APFloat.cpp.
Referenced by mod().
|
friend |
Returns: X * 2^Exp for integral exponents.
Referenced by mod().