llvm::APFloat

Arbitrary-precision floating-point value.

Synopsis

Declared in <llvm/ADT/APFloat.h>

class APFloat
    : public APFloatBase

Base Classes

NameDescription
APFloatBaseShared type definitions for APFloat and its internal implementation classes.

Type Aliases

NameDescription
ExponentType A signed type to represent a floating point numbers unbiased exponent.
integerPart Unsigned word type used for multi-precision integer parts of a float.
roundingMode IEEE-754R 4.3: Rounding-direction attributes.

Enums

NameDescription
IlogbErrorKinds Enumeration of ilogb error results.
Semantics @{ Identifiers for the built-in floating-point formats APFloat supports.
cmpResult IEEE-754R 5.11: Floating Point Comparison Relations.
fltCategory Category of internally-represented number.
opStatus IEEE-754R 7: Default exception handling.
uninitializedTag Convenience enum used to construct an uninitialized APFloat.

Member Functions

NameDescription
APFloat [constructor]Constructors
~APFloat [destructor]Destroy this APFloat, releasing any owned heap storage.
operator= Assignment operators
Profile Used to insert APFloat objects, or objects that contain APFloat objects, into FoldingSets.
add Add RHS to this value, rounding with RM; store the sum in-place.
bitcastToAPInt Return the IEEE bit pattern of this value as an APInt.
bitwiseIsEqual Return true if this value and RHS have identical semantics and bits.
changeSign Flip the sign bit of this value.
classify Return the FPClassTest which will return true for the value.
clearSign Force the sign bit clear (make the value non-negative).
compare IEEE comparison with RHS (NaNs compare unordered; +0 equals -0).
compareAbsoluteValue Compare absolute values; both operands must be finite and non-zero.
convert Convert this value to ToSemantics, rounding with RM.
convertFromAPInt Convert a two's complement integer Input to this floating-point value.
convertFromString Fill this APFloat with the result of a string conversion.
convertToDouble Converts this APFloat to host double value.
convertToFloat Converts this APFloat to host float value.
convertToHexString Write a C99 %a/%A-style hex float into DST and return characters written.
convertToInteger convertToInteger overloads
convertToQuad
copySign Copy the sign bit from RHS onto this value.
divide Divide this value by RHS, rounding with RM; store the quotient in-place.
dump Print this value to stderr for debugging.
fusedMultiplyAdd Compute this * Multiplicand + Addend with a single rounding under RM.
getCategory Return the IEEE category of this value.
getExactInverse If this value is normal and has an exact, normal, multiplicative inverse, store it in inv and return true.
getExactLog2 If this is an exact positive power of two, return its exponent; else INT_MIN.
getExactLog2Abs If this is an exact power of two, return the exponent while ignoring the sign bit. If it's not an exact power of 2, return INT_MIN.
getNaNPayload If the value is a NaN value, return an integer containing the payload of this value. This payload will include the quiet bit as part of the returned integer.
getSemantics Return the floating-point semantics of this value.
isDenormal Return true if this value is a denormal (subnormal) number.
isExactlyValue Return true if this value is bit-for-bit identical to host double V.
isFinite Return true if this value is finite (not Inf or NaN).
isFiniteNonZero Return true if this value is finite and non-zero.
isInfinity Return true if this value is positive or negative infinity.
isInteger Return true if this value is an exact integer (no fractional part).
isLargest Return true if this is the largest-magnitude finite value of its format.
isMinusOne Return true if this value is exactly -1.0.
isNaN Return true if this value is a NaN.
isNegInfinity Return true if this value is -Inf.
isNegPowerOf2 Return true if this value is exactly -(2^N).
isNegZero Return true if this value is -0.
isNegative Return true if the sign bit is set.
isNonZero Return true if this value is not zero.
isNormal Return true if this value is a normal (not denormal) finite non-zero number.
isOne Return true if this value is exactly +1.0.
isPosInfinity Return true if this value is +Inf.
isPosZero Return true if this value is +0.
isPowerOf2 Return true if this value is exactly 2^N.
isSignaling Return true if this value is a signaling NaN.
isSmallest Return true if this is the smallest-magnitude finite value of its format.
isSmallestNormalized Return true if this is the smallest-magnitude normalized finite value.
isZero Return true if this value is positive or negative zero.
makeQuiet Assuming this is an IEEE-754 NaN value, quiet its signaling bit. This preserves the sign and payload bits.
mod Compute C99 fmod of this value by RHS; store the result in-place.
multiply Multiply this value by RHS, rounding with RM; store the product in-place.
needsCleanup Return true if this value owns heap storage that must be freed.
next Move to the next or previous representable value.
operator* Multiply two APFloats, rounding ties to the nearest even. No error checking.
operator+ Add two APFloats, rounding ties to the nearest even. No error checking.
operator- Unary minus operators
operator/ Divide the first APFloat by the second, rounding ties to the nearest even. No error checking.
print Print a textual representation of this value to OS.
remainder Compute the IEEE remainder of this value by RHS; store the result in-place.
roundToIntegral Round this value to an integral floating-point value using RM.
subtract Subtract RHS from this value, rounding with RM; store the difference in-place.
toString Append a decimal text representation of this value to Str.
operator== Return true if this value compares equal to RHS (NaNs are never equal).
operator!= Return true if this value does not compare equal to RHS.
operator< Return true if this value is ordered less than RHS.
operator<= Return true if this value is ordered less than or equal to RHS.
operator> Return true if this value is ordered greater than RHS.
operator>= Return true if this value is ordered greater than or equal to RHS.

Static Member Functions

NameDescription
BFloat Return bfloat16 semantics.
Bogus A Pseudo fltsemantic used to construct APFloats that cannot conflict with anything real.
EnumToSemantics Map a Semantics enumerator to its corresponding fltSemantics.
Float4E2M1FN Return 4-bit S1E2M1 finite-only floating-point semantics.
Float6E2M3FN Return 6-bit S1E2M3 finite-only floating-point semantics.
Float6E3M2FN Return 6-bit S1E3M2 finite-only floating-point semantics.
Float8E3M4 Return 8-bit S1E3M4 floating-point semantics.
Float8E4M3 Return 8-bit S1E4M3 floating-point semantics.
Float8E4M3B11FNUZ Return 8-bit S1E4M3 bias-11 finite / unsigned-zero floating-point semantics.
Float8E4M3FN Return 8-bit S1E4M3 finite-only floating-point semantics.
Float8E4M3FNUZ Return 8-bit S1E4M3 finite / unsigned-zero floating-point semantics.
Float8E5M2 Return 8-bit S1E5M2 floating-point semantics.
Float8E5M2FNUZ Return 8-bit S1E5M2 finite / unsigned-zero floating-point semantics.
Float8E5M3FNU Return 8-bit S0E5M3 floating-point semantics.
Float8E8M0FNU Return 8-bit unsigned E8M0 scale floating-point semantics.
FloatTF32 Return TensorFloat-32 semantics.
IEEEdouble Return IEEE 754 binary64 (double) semantics.
IEEEhalf Return IEEE 754 binary16 (half) semantics.
IEEEquad Return IEEE 754 binary128 (quad) semantics.
IEEEsingle Return IEEE 754 binary32 (single) semantics.
PPCDoubleDouble Return IBM double-double semantics.
PPCDoubleDoubleLegacy Return legacy IBM double-double (consecutive 106-bit mantissa) semantics.
SemanticsToEnum Map a fltSemantics object to its corresponding Semantics enumerator.
copySign A static helper to produce a copy of an APFloat value with its sign copied from some other APFloat.
getAllOnesValue Returns a float which is bitcasted from an all one value int.
getArbitraryFPFormatSizeInBits Return the size in bits of a valid arbitrary floating-point format string.
getArbitraryFPSemantics Returns the fltSemantics for a given arbitrary FP format string, or nullptr if invalid.
getInf Factory for Positive and Negative Infinity.
getLargest Returns the largest finite number in the given semantics.
getNaN Factory for NaN values.
getOne Factory for Positive and Negative One.
getQNaN Factory for QNaN values.
getSNaN Factory for SNaN values.
getSizeInBits Returns the size of the floating point number (in bits) in the given semantics.
getSmallest Returns the smallest (by magnitude) finite number in the given semantics. Might be denormalized, which implies a relative loss of precision.
getSmallestNormalized Returns the smallest (by magnitude) normalized finite number in the given semantics.
getZero Factory for Positive and Negative Zero.
hasSignBitInMSB Return true if the sign bit of Sem is the most significant bit.
hasSignificand Returns true if the given semantics has actual significand.
isIEEELikeFP Return true if Sem follows IEEE-like encoding conventions.
isRepresentableAsNormalIn Returns true if any number described by Src can be precisely represented by a normal (not subnormal) value in Dst.
isRepresentableBy Return true if every finite value of semantics A is exactly representable in semantics B.
isValidArbitraryFPFormat Return true if Format is a valid arbitrary floating-point format string.
semanticsHasInf Return true if Sem encodes infinities.
semanticsHasNaN Return true if Sem encodes NaN values.
semanticsHasSignedRepr Return true if Sem can represent signed values.
semanticsHasZero Return true if Sem encodes a zero value.
semanticsIntSizeInBits Return how many integer bits are needed to hold values of Sem.
semanticsMaxExponent Return the maximum unbiased exponent of Sem.
semanticsMinExponent Return the minimum normalized unbiased exponent of Sem.
semanticsPrecision Return the significand precision (including the integer bit) of Sem.
semanticsSizeInBits Return the storage size in bits of a value with semantics Sem.
x87DoubleExtended Return x87 80-bit double-extended semantics.

Static Data Members

NameDescription
integerPartWidth Number of bits in one integerPart word.
rmNearestTiesToAway Round to nearest, ties away from zero.
rmNearestTiesToEven Round to nearest, ties to even (IEEE default).
rmTowardNegative Round toward negative infinity.
rmTowardPositive Round toward positive infinity.
rmTowardZero Round toward zero (truncate).

Friends

NameDescription
llvm::APFloat::DoubleAPFloat
llvm::APFloat::IEEEFloat
llvm::frexpEquivalent of C standard library function.
llvm::scalbnReturns: X * 2^Exp for integral exponents.
llvm::ilogbReturns the exponent of the internal representation of the APFloat.
llvm::hash_valueSee friend declarations above.

Non-Member Functions

NameDescription
ConstantFoldFPBinOpConstant-fold a generic floating-point binary opcode on two registers.
ConstantFoldIntToFloatConstant-fold an integer-to-float conversion opcode.
absReturns the absolute value of the argument.
expImplement IEEE 754-2019 exp functions
isConstantOrConstantSplatVectorFPDetermines if Def defines a float constant integer or a splat vector of float constant integers.
maximumImplements IEEE 754-2019 maximum semantics. Returns the larger of 2 arguments, returning a quiet NaN if an argument is a NaN and treating -0 as less than +0.
maximumnumImplements IEEE 754-2019 maximumNumber semantics. Returns the larger of 2 arguments, not propagating NaNs and treating -0 as less than +0.
maxnumIEEE-754-2008 maxNum: return the larger of two values.
minimumImplements IEEE 754-2019 minimum semantics. Returns the smaller of 2 arguments, returning a quiet NaN if an argument is a NaN and treating -0 as less than +0.
minimumnumImplements IEEE 754-2019 minimumNumber semantics. Returns the smaller of 2 arguments, not propagating NaNs and treating -0 as less than +0.
minnumIEEE-754-2008 minNum: return the smaller of two values.
negReturns the negated value of the argument.
PatternMatch::m_APFloatMatch a ConstantFP or splatted ConstantVector, binding the specified pointer to the contained APFloat.
PatternMatch::m_APFloatAllowPoisonMatch APFloat while allowing poison in splat vector constants.
PatternMatch::m_APFloatForbidPoisonMatch APFloat while forbidding poison in splat vector constants.
PatternMatch::m_FiniteMatch a finite FP constant and bind the APFloat.
PatternMatch::m_FiniteNonZeroMatch a finite non-zero FP constant and bind the APFloat.
SDPatternMatch::m_SpecificFPMatch a specific float constant.