LLVM 20.0.0git
Classes | Public Member Functions | Friends | List of all members
llvm::detail::IEEEFloat Class Referencefinal

#include "llvm/ADT/APFloat.h"

Inheritance diagram for llvm::detail::IEEEFloat:
Inheritance graph
[legend]

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.
 
IEEEFloatoperator= (const IEEEFloat &)
 
IEEEFloatoperator= (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.
 
LLVM_READONLY int getExactLog2Abs () const
 
LLVM_READONLY int getExactLog2 () const
 
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< opStatusconvertFromString (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 fltSemanticsgetSemantics () 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.
 

Additional Inherited Members

- Public Types inherited from llvm::APFloatBase
enum  cmpResult { cmpLessThan , cmpEqual , cmpGreaterThan , cmpUnordered }
 IEEE-754R 5.11: Floating Point Comparison Relations. More...
 
enum  opStatus {
  opOK = 0x00 , opInvalidOp = 0x01 , opDivByZero = 0x02 , opOverflow = 0x04 ,
  opUnderflow = 0x08 , opInexact = 0x10
}
 IEEE-754R 7: Default exception handling. More...
 
enum  fltCategory { fcInfinity , fcNaN , fcNormal , fcZero }
 Category of internally-represented number. More...
 
enum  uninitializedTag { uninitialized }
 Convenience enum used to construct an uninitialized APFloat. More...
 
enum  IlogbErrorKinds { IEK_Zero = INT_MIN + 1 , IEK_NaN = INT_MIN , IEK_Inf = INT_MAX }
 Enumeration of ilogb error results. More...
 
typedef APInt::WordType integerPart
 
typedef int32_t ExponentType
 A signed type to represent a floating point numbers unbiased exponent.
 
using roundingMode = llvm::RoundingMode
 IEEE-754R 4.3: Rounding-direction attributes.
 
enum  Semantics {
  S_IEEEhalf , S_BFloat , S_IEEEsingle , S_IEEEdouble ,
  S_IEEEquad , S_PPCDoubleDouble , S_Float8E5M2 , S_Float8E5M2FNUZ ,
  S_Float8E4M3 , S_Float8E4M3FN , S_Float8E4M3FNUZ , S_Float8E4M3B11FNUZ ,
  S_Float8E3M4 , S_FloatTF32 , S_Float6E3M2FN , S_Float6E2M3FN ,
  S_Float4E2M1FN , S_x87DoubleExtended , S_MaxSemantics = S_x87DoubleExtended
}
 
- Static Public Member Functions inherited from llvm::APFloatBase
static unsigned int semanticsPrecision (const fltSemantics &)
 
static ExponentType semanticsMinExponent (const fltSemantics &)
 
static ExponentType semanticsMaxExponent (const fltSemantics &)
 
static unsigned int semanticsSizeInBits (const fltSemantics &)
 
static unsigned int semanticsIntSizeInBits (const fltSemantics &, bool)
 
static bool isRepresentableAsNormalIn (const fltSemantics &Src, const fltSemantics &Dst)
 
static unsigned getSizeInBits (const fltSemantics &Sem)
 Returns the size of the floating point number (in bits) in the given semantics.
 
static const llvm::fltSemanticsEnumToSemantics (Semantics S)
 
static Semantics SemanticsToEnum (const llvm::fltSemantics &Sem)
 
static const fltSemanticsIEEEhalf () LLVM_READNONE
 
static const fltSemanticsBFloat () LLVM_READNONE
 
static const fltSemanticsIEEEsingle () LLVM_READNONE
 
static const fltSemanticsIEEEdouble () LLVM_READNONE
 
static const fltSemanticsIEEEquad () LLVM_READNONE
 
static const fltSemanticsPPCDoubleDouble () LLVM_READNONE
 
static const fltSemanticsFloat8E5M2 () LLVM_READNONE
 
static const fltSemanticsFloat8E5M2FNUZ () LLVM_READNONE
 
static const fltSemanticsFloat8E4M3 () LLVM_READNONE
 
static const fltSemanticsFloat8E4M3FN () LLVM_READNONE
 
static const fltSemanticsFloat8E4M3FNUZ () LLVM_READNONE
 
static const fltSemanticsFloat8E4M3B11FNUZ () LLVM_READNONE
 
static const fltSemanticsFloat8E3M4 () LLVM_READNONE
 
static const fltSemanticsFloatTF32 () LLVM_READNONE
 
static const fltSemanticsFloat6E3M2FN () LLVM_READNONE
 
static const fltSemanticsFloat6E2M3FN () LLVM_READNONE
 
static const fltSemanticsFloat4E2M1FN () LLVM_READNONE
 
static const fltSemanticsx87DoubleExtended () LLVM_READNONE
 
static const fltSemanticsBogus () LLVM_READNONE
 A Pseudo fltsemantic used to construct APFloats that cannot conflict with anything real.
 
- Static Public Attributes inherited from llvm::APFloatBase
static constexpr unsigned integerPartWidth = APInt::APINT_BITS_PER_WORD
 
static constexpr roundingMode rmNearestTiesToEven
 
static constexpr roundingMode rmTowardPositive = RoundingMode::TowardPositive
 
static constexpr roundingMode rmTowardNegative = RoundingMode::TowardNegative
 
static constexpr roundingMode rmTowardZero = RoundingMode::TowardZero
 
static constexpr roundingMode rmNearestTiesToAway
 

Detailed Description

Definition at line 317 of file APFloat.h.

Constructor & Destructor Documentation

◆ IEEEFloat() [1/8]

llvm::detail::IEEEFloat::IEEEFloat ( const fltSemantics ourSemantics)

Definition at line 1166 of file APFloat.cpp.

References makeZero().

◆ IEEEFloat() [2/8]

llvm::detail::IEEEFloat::IEEEFloat ( const fltSemantics ourSemantics,
integerPart  value 
)

◆ IEEEFloat() [3/8]

llvm::detail::IEEEFloat::IEEEFloat ( const fltSemantics ourSemantics,
uninitializedTag  tag 
)

Definition at line 1173 of file APFloat.cpp.

◆ IEEEFloat() [4/8]

llvm::detail::IEEEFloat::IEEEFloat ( const fltSemantics Sem,
const APInt API 
)

Definition at line 4067 of file APFloat.cpp.

◆ IEEEFloat() [5/8]

llvm::detail::IEEEFloat::IEEEFloat ( double  d)
explicit

Definition at line 4075 of file APFloat.cpp.

References llvm::APInt::doubleToBits(), and llvm::semIEEEdouble.

◆ IEEEFloat() [6/8]

llvm::detail::IEEEFloat::IEEEFloat ( float  f)
explicit

Definition at line 4071 of file APFloat.cpp.

References llvm::APInt::floatToBits(), and llvm::semIEEEsingle.

◆ IEEEFloat() [7/8]

llvm::detail::IEEEFloat::IEEEFloat ( const IEEEFloat rhs)

Definition at line 1176 of file APFloat.cpp.

◆ IEEEFloat() [8/8]

llvm::detail::IEEEFloat::IEEEFloat ( IEEEFloat &&  rhs)

Definition at line 1181 of file APFloat.cpp.

◆ ~IEEEFloat()

llvm::detail::IEEEFloat::~IEEEFloat ( )

Definition at line 1185 of file APFloat.cpp.

Member Function Documentation

◆ add()

IEEEFloat::opStatus llvm::detail::IEEEFloat::add ( const IEEEFloat rhs,
roundingMode  rounding_mode 
)

Definition at line 2077 of file APFloat.cpp.

Referenced by remainder(), and roundToIntegral().

◆ bitcastToAPInt()

APInt llvm::detail::IEEEFloat::bitcastToAPInt ( ) const

◆ bitwiseIsEqual()

bool llvm::detail::IEEEFloat::bitwiseIsEqual ( const IEEEFloat rhs) const

Bitwise comparison for equality (QNaNs compare equal, 0!=-0).

Definition at line 1139 of file APFloat.cpp.

References llvm::APFloatBase::fcInfinity, llvm::APFloatBase::fcZero, and isFiniteNonZero().

◆ changeSign()

void llvm::detail::IEEEFloat::changeSign ( )

Definition at line 2033 of file APFloat.cpp.

References isNaN(), isZero(), llvm::fltSemantics::nanEncoding, and llvm::NegativeZero.

Referenced by roundToIntegral().

◆ compare()

IEEEFloat::cmpResult llvm::detail::IEEEFloat::compare ( const IEEEFloat rhs) const

◆ compareAbsoluteValue()

IEEEFloat::cmpResult llvm::detail::IEEEFloat::compareAbsoluteValue ( const IEEEFloat rhs) const

◆ convert()

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 2476 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().

◆ convertFromAPInt()

IEEEFloat::opStatus llvm::detail::IEEEFloat::convertFromAPInt ( const APInt Val,
bool  isSigned,
roundingMode  rounding_mode 
)

◆ convertFromSignExtendedInteger()

IEEEFloat::opStatus llvm::detail::IEEEFloat::convertFromSignExtendedInteger ( const integerPart src,
unsigned int  srcCount,
bool  isSigned,
roundingMode  rounding_mode 
)

◆ convertFromString()

Expected< IEEEFloat::opStatus > llvm::detail::IEEEFloat::convertFromString ( StringRef  str,
roundingMode  rounding_mode 
)

◆ convertFromZeroExtendedInteger()

IEEEFloat::opStatus llvm::detail::IEEEFloat::convertFromZeroExtendedInteger ( const integerPart parts,
unsigned int  width,
bool  isSigned,
roundingMode  rounding_mode 
)

◆ convertToDouble()

double llvm::detail::IEEEFloat::convertToDouble ( ) const

◆ convertToFloat()

float llvm::detail::IEEEFloat::convertToFloat ( ) const

◆ convertToHexString()

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 3281 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.

◆ convertToInteger()

IEEEFloat::opStatus llvm::detail::IEEEFloat::convertToInteger ( MutableArrayRef< integerPart parts,
unsigned int  width,
bool  isSigned,
roundingMode  rounding_mode,
bool isExact 
) const

◆ divide()

IEEEFloat::opStatus llvm::detail::IEEEFloat::divide ( const IEEEFloat rhs,
roundingMode  rounding_mode 
)

◆ fusedMultiplyAdd()

IEEEFloat::opStatus llvm::detail::IEEEFloat::fusedMultiplyAdd ( const IEEEFloat multiplicand,
const IEEEFloat addend,
roundingMode  rounding_mode 
)

◆ getCategory()

fltCategory llvm::detail::IEEEFloat::getCategory ( ) const
inline

Definition at line 448 of file APFloat.h.

Referenced by llvm::APFloat::getCategory(), and isSmallestNormalized().

◆ getExactInverse()

bool llvm::detail::IEEEFloat::getExactInverse ( APFloat inv) const

If this value has an exact multiplicative inverse, store it in inv and return true.

Definition at line 4399 of file APFloat.cpp.

References assert(), divide(), isDenormal(), isFiniteNonZero(), and llvm::fltSemantics::precision.

◆ getExactLog2()

LLVM_READONLY int llvm::detail::IEEEFloat::getExactLog2 ( ) const
inline

Definition at line 527 of file APFloat.h.

References getExactLog2Abs(), and isNegative().

◆ getExactLog2Abs()

int llvm::detail::IEEEFloat::getExactLog2Abs ( ) const

◆ getSemantics()

const fltSemantics & llvm::detail::IEEEFloat::getSemantics ( ) const
inline

Definition at line 449 of file APFloat.h.

◆ isDenormal()

bool llvm::detail::IEEEFloat::isDenormal ( ) const

IEEE-754R isSubnormal(): Returns true if and only if the float is a denormal.

Definition at line 1009 of file APFloat.cpp.

References isFiniteNonZero(), llvm::fltSemantics::minExponent, llvm::fltSemantics::precision, and llvm::APInt::tcExtractBit().

Referenced by getExactInverse(), and isNormal().

◆ isFinite()

bool llvm::detail::IEEEFloat::isFinite ( ) const
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 425 of file APFloat.h.

References isInfinity(), and isNaN().

Referenced by fusedMultiplyAdd(), isFiniteNonZero(), and isInteger().

◆ isFiniteNonZero()

bool llvm::detail::IEEEFloat::isFiniteNonZero ( ) const
inline

◆ isInfinity()

bool llvm::detail::IEEEFloat::isInfinity ( ) const
inline

IEEE-754R isInfinite(): Returns true if and only if the float is infinity.

Definition at line 435 of file APFloat.h.

References llvm::APFloatBase::fcInfinity.

Referenced by isFinite(), and roundToIntegral().

◆ isInteger()

bool llvm::detail::IEEEFloat::isInteger ( ) const

Returns true if and only if the number is an exact integer.

Definition at line 1131 of file APFloat.cpp.

References llvm::APFloatBase::cmpEqual, compare(), isFinite(), llvm::APFloatBase::rmTowardZero, and llvm::truncated.

◆ isLargest()

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 1115 of file APFloat.cpp.

References llvm::AllOnes, isFiniteNonZero(), llvm::fltSemantics::maxExponent, llvm::fltSemantics::nanEncoding, llvm::NanOnly, and llvm::fltSemantics::nonFiniteBehavior.

◆ isNaN()

bool llvm::detail::IEEEFloat::isNaN ( ) const
inline

Returns true if and only if the float is a quiet or signaling NaN.

Definition at line 438 of file APFloat.h.

References llvm::APFloatBase::fcNaN.

Referenced by changeSign(), isFinite(), and roundToIntegral().

◆ isNegative()

bool llvm::detail::IEEEFloat::isNegative ( ) const
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 413 of file APFloat.h.

Referenced by getExactLog2(), llvm::APFloat::isNegative(), isNegZero(), isPosZero(), and roundToIntegral().

◆ isNegZero()

bool llvm::detail::IEEEFloat::isNegZero ( ) const
inline

Definition at line 453 of file APFloat.h.

References isNegative(), and isZero().

◆ isNonZero()

bool llvm::detail::IEEEFloat::isNonZero ( ) const
inline

Definition at line 450 of file APFloat.h.

References llvm::APFloatBase::fcZero.

◆ isNormal()

bool llvm::detail::IEEEFloat::isNormal ( ) const
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 419 of file APFloat.h.

References isDenormal(), and isFiniteNonZero().

◆ isPosZero()

bool llvm::detail::IEEEFloat::isPosZero ( ) const
inline

Definition at line 452 of file APFloat.h.

References isNegative(), and isZero().

◆ isSignaling()

bool llvm::detail::IEEEFloat::isSignaling ( ) const

Returns true if and only if the float is a signaling NaN.

Definition at line 4457 of file APFloat.cpp.

References llvm::FiniteOnly, llvm::NanOnly, and llvm::APInt::tcExtractBit().

Referenced by convert(), llvm::APFloat::isSignaling(), and roundToIntegral().

◆ isSmallest()

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 1015 of file APFloat.cpp.

References isFiniteNonZero(), and llvm::fltSemantics::minExponent.

◆ isSmallestNormalized()

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 1023 of file APFloat.cpp.

References llvm::APFloatBase::fcNormal, getCategory(), and llvm::fltSemantics::minExponent.

◆ isZero()

bool llvm::detail::IEEEFloat::isZero ( ) const
inline

Returns true if and only if the float is plus or minus zero.

Definition at line 428 of file APFloat.h.

References llvm::APFloatBase::fcZero.

Referenced by changeSign(), divide(), isFiniteNonZero(), isNegZero(), isPosZero(), mod(), multiply(), remainder(), and roundToIntegral().

◆ makeInf()

void llvm::detail::IEEEFloat::makeInf ( bool  Neg = false)

◆ makeLargest()

void llvm::detail::IEEEFloat::makeLargest ( bool  Neg = false)

Make this number the largest magnitude normal number in the given semantics.

Definition at line 4014 of file APFloat.cpp.

References llvm::AllOnes, llvm::fcNormal, and llvm::NanOnly.

◆ makeNaN()

void llvm::detail::IEEEFloat::makeNaN ( bool  SNaN = false,
bool  Neg = false,
const APInt fill = nullptr 
)

◆ makeQuiet()

void llvm::detail::IEEEFloat::makeQuiet ( )

Definition at line 4639 of file APFloat.cpp.

References assert(), llvm::NanOnly, and llvm::APInt::tcSetBit().

Referenced by convert(), and roundToIntegral().

◆ makeSmallest()

void llvm::detail::IEEEFloat::makeSmallest ( bool  Neg = false)

Make this number the smallest magnitude denormal number in the given semantics.

Definition at line 4043 of file APFloat.cpp.

References llvm::fcNormal, and llvm::APInt::tcSet().

◆ makeSmallestNormalized()

void llvm::detail::IEEEFloat::makeSmallestNormalized ( bool  Negative = false)

Returns the smallest (by magnitude) normalized finite number in the given semantics.

Parameters
Negative- True iff the number should be negative

Definition at line 4054 of file APFloat.cpp.

References llvm::fcNormal, and llvm::APInt::tcSetBit().

◆ makeZero()

void llvm::detail::IEEEFloat::makeZero ( bool  Neg = false)

Definition at line 4628 of file APFloat.cpp.

References llvm::exponentZero(), llvm::fcZero, llvm::NegativeZero, and llvm::APInt::tcSet().

Referenced by IEEEFloat().

◆ mod()

IEEEFloat::opStatus llvm::detail::IEEEFloat::mod ( const IEEEFloat rhs)

◆ multiply()

IEEEFloat::opStatus llvm::detail::IEEEFloat::multiply ( const IEEEFloat rhs,
roundingMode  rounding_mode 
)

◆ needsCleanup()

bool llvm::detail::IEEEFloat::needsCleanup ( ) const
inline

Returns whether this instance allocated memory.

Definition at line 335 of file APFloat.h.

◆ next()

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 4473 of file APFloat.cpp.

References assert(), llvm::fcNormal, llvm::fcZero, llvm::FiniteOnly, llvm::NanOnly, llvm::NegativeZero, llvm::APInt::tcDecrement(), llvm::APInt::tcSet(), and llvm::APInt::tcSetBit().

◆ operator=() [1/2]

IEEEFloat & llvm::detail::IEEEFloat::operator= ( const IEEEFloat rhs)

Definition at line 984 of file APFloat.cpp.

◆ operator=() [2/2]

IEEEFloat & llvm::detail::IEEEFloat::operator= ( IEEEFloat &&  rhs)

Definition at line 996 of file APFloat.cpp.

References llvm::semBogus.

◆ operator==()

bool llvm::detail::IEEEFloat::operator== ( const IEEEFloat ) const
delete

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.

◆ remainder()

IEEEFloat::opStatus llvm::detail::IEEEFloat::remainder ( const IEEEFloat rhs)

◆ roundToIntegral()

IEEEFloat::opStatus llvm::detail::IEEEFloat::roundToIntegral ( roundingMode  rounding_mode)

◆ subtract()

IEEEFloat::opStatus llvm::detail::IEEEFloat::subtract ( const IEEEFloat rhs,
roundingMode  rounding_mode 
)

Definition at line 2083 of file APFloat.cpp.

Referenced by mod(), remainder(), and roundToIntegral().

◆ toString()

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.

Parameters
FormatPrecisionThe 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.
FormatMaxPaddingThe maximum number of zeros to consider inserting before falling back to scientific notation. 0 means to always use scientific notation.
TruncateZeroIndicate 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 4356 of file APFloat.cpp.

References llvm::fcNormal, llvm::fcZero, and llvm::partCountForBits().

Friends And Related Function Documentation

◆ frexp

IEEEFloat frexp ( const IEEEFloat X,
int &  Exp,
roundingMode   
)
friend

◆ hash_value

hash_code hash_value ( const IEEEFloat Arg)
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 3430 of file APFloat.cpp.

◆ ilogb

int ilogb ( const IEEEFloat Arg)
friend

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 4645 of file APFloat.cpp.

Referenced by mod().

◆ scalbn

IEEEFloat scalbn ( IEEEFloat  X,
int  Exp,
roundingMode   
)
friend

Returns: X * 2^Exp for integral exponents.

Referenced by mod().


The documentation for this class was generated from the following files: