Quick Links:

bal | bbl | bdl | bsl

Public Types | Static Public Member Functions

bdlb::Float Struct Reference

#include <bdlb_float.h>

List of all members.

Public Types

enum  Classification {
  k_ZERO = 0x01, k_NORMAL = 0x02, k_SUBNORMAL = 0x04, k_INFINITE = 0x08,
  k_NAN = 0x10, BDES_ZERO = k_ZERO, BDES_NORMAL = k_NORMAL, BDES_SUBNORMAL = k_SUBNORMAL,
  BDES_INFINITE = k_INFINITE, BDES_NAN = k_NAN
}
enum  FineClassification {
  k_NEGATIVE = 0x8000, k_SIGNALING = 0x4000, k_POSITIVE_INFINITY = k_INFINITE, k_NEGATIVE_INFINITY = k_INFINITE | k_NEGATIVE,
  k_QNAN = k_NAN, k_SNAN = k_NAN | k_SIGNALING, k_POSITIVE_NORMAL = k_NORMAL, k_NEGATIVE_NORMAL = k_NORMAL | k_NEGATIVE,
  k_POSITIVE_SUBNORMAL = k_SUBNORMAL, k_NEGATIVE_SUBNORMAL = k_SUBNORMAL | k_NEGATIVE, k_POSITIVE_ZERO = k_ZERO, k_NEGATIVE_ZERO = k_ZERO | k_NEGATIVE,
  BDES_NEGATIVE = k_NEGATIVE, BDES_SIGNALING = k_SIGNALING, BDES_POSITIVE_INFINITY = k_POSITIVE_INFINITY, BDES_NEGATIVE_INFINITY = k_NEGATIVE_INFINITY,
  BDES_QNAN = k_QNAN, BDES_SNAN = k_SNAN, BDES_POSITIVE_NORMAL = k_POSITIVE_NORMAL, BDES_NEGATIVE_NORMAL = k_NEGATIVE_NORMAL,
  BDES_POSITIVE_SUBNORMAL = k_POSITIVE_SUBNORMAL, BDES_NEGATIVE_SUBNORMAL = k_NEGATIVE_SUBNORMAL, BDES_POSITIVE_ZERO = k_POSITIVE_ZERO, BDES_NEGATIVE_ZERO = k_NEGATIVE_ZERO
}

Static Public Member Functions

static Classification classify (float number)
static Classification classify (double number)
static FineClassification classifyFine (float number)
static FineClassification classifyFine (double number)
static bool isZero (float number)
static bool isZero (double number)
static bool isNormal (float number)
static bool isNormal (double number)
static bool isSubnormal (float number)
static bool isSubnormal (double number)
static bool isInfinite (float number)
static bool isInfinite (double number)
static bool isNan (float number)
static bool isNan (double number)
static bool signBit (float number)
static bool signBit (double number)
static bool isFinite (float number)
static bool isFinite (double number)
static bool isQuietNan (float number)
static bool isQuietNan (double number)
static bool isSignalingNan (float number)
static bool isSignalingNan (double number)

Detailed Description

Namespace for floating-point classification types and functions.

See Component bdlb_float


Member Enumeration Documentation

Basic classifications for floating-point numbers. Every floating-point number belongs to exactly one of these classifications. However, the enumerated values have disjoint bit-patterns to make it easy to create a "set" of classifications using bit-wise OR.

Enumerator:
k_ZERO 

positive or negative zero

k_NORMAL 

full-precision, non-zero, normal number

k_SUBNORMAL 

reduced-precision numb with a small abs value

k_INFINITE 

positive or negative infinity

k_NAN 

not a number

BDES_ZERO 
BDES_NORMAL 
BDES_SUBNORMAL 
BDES_INFINITE 
BDES_NAN 

Fine-grained classifications for floating-point numbers that distinguish positive numbers from negative numbers and quiet NaNs from signaling NaNs. Every floating-point number belongs to exactly one of these classifications.

Enumerator:
k_NEGATIVE 

Bit for negative floats.

k_SIGNALING 

Bit for signaling NaNs.

k_POSITIVE_INFINITY 
k_NEGATIVE_INFINITY 
k_QNAN 
k_SNAN 
k_POSITIVE_NORMAL 
k_NEGATIVE_NORMAL 
k_POSITIVE_SUBNORMAL 
k_NEGATIVE_SUBNORMAL 
k_POSITIVE_ZERO 
k_NEGATIVE_ZERO 
BDES_NEGATIVE 
BDES_SIGNALING 
BDES_POSITIVE_INFINITY 
BDES_NEGATIVE_INFINITY 
BDES_QNAN 
BDES_SNAN 
BDES_POSITIVE_NORMAL 
BDES_NEGATIVE_NORMAL 
BDES_POSITIVE_SUBNORMAL 
BDES_NEGATIVE_SUBNORMAL 
BDES_POSITIVE_ZERO 
BDES_NEGATIVE_ZERO 

Member Function Documentation

static Classification bdlb::Float::classify ( float  number  )  [static]
static Classification bdlb::Float::classify ( double  number  )  [static]

Return the coarse classification (k_ZERO, k_NORMAL, k_SUBNORMAL, k_INFINITE, or 'k_NAN) for the specified floating point number. This function has the same functionality as the fpclassify macro in C99.

static FineClassification bdlb::Float::classifyFine ( float  number  )  [static]
static FineClassification bdlb::Float::classifyFine ( double  number  )  [static]

Return the fine-grained classification for the specified floating point number. For positive numbers and quiet NaNs, the classifyFine function returns the same integer value as classify. For negative numbers, classifyFine returns an integer value equal to value returned by classify bit-wise OR'ed with k_NEGATIVE. For signaling NaNs, classifyFine returns k_SNAN, which has the integer value of k_NAN | k_SIGNALING.

static bool bdlb::Float::isZero ( float  number  )  [static]
static bool bdlb::Float::isZero ( double  number  )  [static]

Return true if the specified floating point number has a value of positive or negative zero, and false otherwise.

static bool bdlb::Float::isNormal ( float  number  )  [static]
static bool bdlb::Float::isNormal ( double  number  )  [static]

Return true if the specified floating point number holds a normal value (neither zero, subnormal, infinite, nor NaN). This function is equivalent to the isnormal macro in C99.

static bool bdlb::Float::isSubnormal ( float  number  )  [static]
static bool bdlb::Float::isSubnormal ( double  number  )  [static]

Return true if the specified floating point number holds a subnormal value, and false otherwise.

static bool bdlb::Float::isInfinite ( float  number  )  [static]
static bool bdlb::Float::isInfinite ( double  number  )  [static]

Return true if the specified floating point number has a value of positive or negative infinity, and false otherwise. This function is equivalent to the isinf macro in C99. Note that infinity is a valid floating-point value and is not a "NaN".

static bool bdlb::Float::isNan ( float  number  )  [static]
static bool bdlb::Float::isNan ( double  number  )  [static]

Return true if the specified floating point number has a value that does not represent a real number ("not-a-number" or "NaN"), and false otherwise. This function is equivalent to the isnan macro in C99. Note that if this method returns true, then either isQuietNan or isSignalingNan will also return true.

static bool bdlb::Float::signBit ( float  number  )  [static]
static bool bdlb::Float::signBit ( double  number  )  [static]

Return true if the specified floating point number has its sign bit set (i.e., it is negative), and false otherwise. This function is equivalent to the signbit macro in C99. Note that this function will return true for some NaNs, even though the concepts of negative and positive do not apply to NaNs.

static bool bdlb::Float::isFinite ( float  number  )  [static]
static bool bdlb::Float::isFinite ( double  number  )  [static]

Return true if the specified floating point number is normal, subnormal or zero, and false if number is infinite or NaN. This function is equivalent to the isfinite macro in C99.

static bool bdlb::Float::isQuietNan ( float  number  )  [static]
static bool bdlb::Float::isQuietNan ( double  number  )  [static]

Return true if the specified floating point number has an indeterminate value, and false otherwise. An indeterminate floating-point value ("quiet NaN" or "QNaN") results from an operation for which the result is not mathematically defined, such as multiplying infinity by zero. If a QNaN is used in a subsequent operations the result will also be a QNaN. Note that, because a QNaN is a NaN, if this method returns true, then isNan(x) will also return true.

static bool bdlb::Float::isSignalingNan ( float  number  )  [static]
static bool bdlb::Float::isSignalingNan ( double  number  )  [static]

Return true if the specified floating point number has an invalid value, and false otherwise. An invalid floating-point value ("signaling NaN" or "SNaN")is never the result of a valid operation -- it must be produced deliberately (i.e., by calling bsl::numeric_limits<float>signaling_NaN()). If an SNaN is used in a subsequent operation, the result is undefined and may result in a hardware trap leading to a signal. Some platforms do not support signaling NaNs, especially for single-precision floats, and will convert an SNaN to a QNaN on assignment or copy-initialization (including argument passing). isSignalingNan will always return false on such platforms. Note that, because an SNaN is a NaN, if this method returns true, then isNan(x) will also return true.


The documentation for this struct was generated from the following file: