template <typename RawType>

class FloatingPoint

Defined at line 245 of file ../../third_party/googletest/src/googletest/include/gtest/internal/gtest-internal.h

This template class represents an IEEE floating-point number

(either single-precision or double-precision, depending on the

template parameters).

The purpose of this class is to do more sophisticated number

comparison. (Due to round-off error, etc, it's very unlikely that

two floating-points will be equal exactly. Hence a naive

comparison by the == operation often doesn't work.)

Format of IEEE floating-point:

The most-significant bit being the leftmost, an IEEE

floating-point looks like

sign_bit exponent_bits fraction_bits

Here, sign_bit is a single bit that designates the sign of the

number.

For float, there are 8 exponent bits and 23 fraction bits.

For double, there are 11 exponent bits and 52 fraction bits.

More details can be found at

https://en.wikipedia.org/wiki/IEEE_floating-point_standard.

Template parameter:

RawType: the raw floating-point type (either float or double)

Public Members

static const size_t kBitCount
static const size_t kFractionBitCount
static const size_t kExponentBitCount
static const Bits kSignBitMask
static const Bits kFractionBitMask
static const Bits kExponentBitMask
static const uint32_t kMaxUlps

Public Methods

void FloatingPoint<RawType> (RawType x)

Constructs a FloatingPoint from a raw floating-point number.

On an Intel CPU, passing a non-normalized NAN (Not a Number)

around may change its bits, although the new value is guaranteed

to be also a NAN. Therefore, don't expect this constructor to

preserve the bits in x when x is a NAN.

Defined at line 293 of file ../../third_party/googletest/src/googletest/include/gtest/internal/gtest-internal.h

RawType ReinterpretBits (Bits bits)

Reinterprets a bit pattern as a floating-point number.

This function is needed to test the AlmostEquals() method.

Defined at line 300 of file ../../third_party/googletest/src/googletest/include/gtest/internal/gtest-internal.h

RawType Infinity ()

Returns the floating-point number that represent positive infinity.

Defined at line 307 of file ../../third_party/googletest/src/googletest/include/gtest/internal/gtest-internal.h

const Bits & bits ()

Returns the bits that represents this number.

Defined at line 312 of file ../../third_party/googletest/src/googletest/include/gtest/internal/gtest-internal.h

Bits exponent_bits ()

Returns the exponent bits of this number.

Defined at line 315 of file ../../third_party/googletest/src/googletest/include/gtest/internal/gtest-internal.h

Bits fraction_bits ()

Returns the fraction bits of this number.

Defined at line 318 of file ../../third_party/googletest/src/googletest/include/gtest/internal/gtest-internal.h

Bits sign_bit ()

Returns the sign bit of this number.

Defined at line 321 of file ../../third_party/googletest/src/googletest/include/gtest/internal/gtest-internal.h

bool is_nan ()

Returns true if and only if this is NAN (not a number).

Defined at line 324 of file ../../third_party/googletest/src/googletest/include/gtest/internal/gtest-internal.h

bool AlmostEquals (const FloatingPoint<RawType> & rhs)

Returns true if and only if this number is at most kMaxUlps ULP's away

from rhs. In particular, this function:

- returns false if either number is (or both are) NAN.

- treats really large numbers as almost equal to infinity.

- thinks +0.0 and -0.0 are 0 ULP's apart.

Defined at line 336 of file ../../third_party/googletest/src/googletest/include/gtest/internal/gtest-internal.h