Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
double_conversion::Single Class Reference

#include <ieee.h>

Public Member Functions

 Single ()
 
 Single (float f)
 
 Single (uint32_t d32)
 
DiyFp AsDiyFp () const
 
uint32_t AsUint32 () const
 
int Exponent () const
 
uint32_t Significand () const
 
bool IsDenormal () const
 
bool IsSpecial () const
 
bool IsNan () const
 
bool IsQuietNan () const
 
bool IsSignalingNan () const
 
bool IsInfinite () const
 
int Sign () const
 
void NormalizedBoundaries (DiyFp *out_m_minus, DiyFp *out_m_plus) const
 
DiyFp UpperBoundary () const
 
bool LowerBoundaryIsCloser () const
 
float value () const
 

Static Public Member Functions

static float Infinity ()
 
static float NaN ()
 

Static Public Attributes

static const uint32_t kSignMask = 0x80000000
 
static const uint32_t kExponentMask = 0x7F800000
 
static const uint32_t kSignificandMask = 0x007FFFFF
 
static const uint32_t kHiddenBit = 0x00800000
 
static const uint32_t kQuietNanBit = 0x00400000
 
static const int kPhysicalSignificandSize = 23
 
static const int kSignificandSize = 24
 

Detailed Description

Definition at line 286 of file ieee.h.

Constructor & Destructor Documentation

◆ Single() [1/3]

double_conversion::Single::Single ( )
inline

Definition at line 296 of file ieee.h.

296: d32_(0) {}

◆ Single() [2/3]

double_conversion::Single::Single ( float  f)
inlineexplicit

Definition at line 297 of file ieee.h.

297: d32_(float_to_uint32(f)) {}
static uint32_t float_to_uint32(float f)
Definition: ieee.h:38

◆ Single() [3/3]

double_conversion::Single::Single ( uint32_t  d32)
inlineexplicit

Definition at line 298 of file ieee.h.

298: d32_(d32) {}

Member Function Documentation

◆ AsDiyFp()

DiyFp double_conversion::Single::AsDiyFp ( ) const
inline

Definition at line 302 of file ieee.h.

302 {
305 return DiyFp(Significand(), Exponent());
306 }
int Exponent() const
Definition: ieee.h:313
bool IsSpecial() const
Definition: ieee.h:340
uint32_t Significand() const
Definition: ieee.h:322
int Sign() const
Definition: ieee.h:374
#define DOUBLE_CONVERSION_ASSERT(condition)
Definition: utils.h:46

◆ AsUint32()

uint32_t double_conversion::Single::AsUint32 ( ) const
inline

Definition at line 309 of file ieee.h.

309 {
310 return d32_;
311 }

◆ Exponent()

int double_conversion::Single::Exponent ( ) const
inline

Definition at line 313 of file ieee.h.

313 {
314 if (IsDenormal()) return kDenormalExponent;
315
316 uint32_t d32 = AsUint32();
317 int biased_e =
318 static_cast<int>((d32 & kExponentMask) >> kPhysicalSignificandSize);
319 return biased_e - kExponentBias;
320 }
static const uint32_t kExponentMask
Definition: ieee.h:289
uint32_t AsUint32() const
Definition: ieee.h:309
bool IsDenormal() const
Definition: ieee.h:333
static const int kPhysicalSignificandSize
Definition: ieee.h:293

◆ Infinity()

static float double_conversion::Single::Infinity ( )
inlinestatic

Definition at line 421 of file ieee.h.

421 {
422 return Single(kInfinity).value();
423 }

◆ IsDenormal()

bool double_conversion::Single::IsDenormal ( ) const
inline

Definition at line 333 of file ieee.h.

333 {
334 uint32_t d32 = AsUint32();
335 return (d32 & kExponentMask) == 0;
336 }

◆ IsInfinite()

bool double_conversion::Single::IsInfinite ( ) const
inline

Definition at line 368 of file ieee.h.

368 {
369 uint32_t d32 = AsUint32();
370 return ((d32 & kExponentMask) == kExponentMask) &&
371 ((d32 & kSignificandMask) == 0);
372 }
static const uint32_t kSignificandMask
Definition: ieee.h:290

◆ IsNan()

bool double_conversion::Single::IsNan ( ) const
inline

Definition at line 345 of file ieee.h.

345 {
346 uint32_t d32 = AsUint32();
347 return ((d32 & kExponentMask) == kExponentMask) &&
348 ((d32 & kSignificandMask) != 0);
349 }

◆ IsQuietNan()

bool double_conversion::Single::IsQuietNan ( ) const
inline

Definition at line 351 of file ieee.h.

351 {
352#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
353 return IsNan() && ((AsUint32() & kQuietNanBit) == 0);
354#else
355 return IsNan() && ((AsUint32() & kQuietNanBit) != 0);
356#endif
357 }
static const uint32_t kQuietNanBit
Definition: ieee.h:292
bool IsNan() const
Definition: ieee.h:345

◆ IsSignalingNan()

bool double_conversion::Single::IsSignalingNan ( ) const
inline

Definition at line 359 of file ieee.h.

359 {
360#if (defined(__mips__) && !defined(__mips_nan2008)) || defined(__hppa__)
361 return IsNan() && ((AsUint32() & kQuietNanBit) != 0);
362#else
363 return IsNan() && ((AsUint32() & kQuietNanBit) == 0);
364#endif
365 }

◆ IsSpecial()

bool double_conversion::Single::IsSpecial ( ) const
inline

Definition at line 340 of file ieee.h.

340 {
341 uint32_t d32 = AsUint32();
342 return (d32 & kExponentMask) == kExponentMask;
343 }

◆ LowerBoundaryIsCloser()

bool double_conversion::Single::LowerBoundaryIsCloser ( ) const
inline

Definition at line 406 of file ieee.h.

406 {
407 // The boundary is closer if the significand is of the form f == 2^p-1 then
408 // the lower boundary is closer.
409 // Think of v = 1000e10 and v- = 9999e9.
410 // Then the boundary (== (v - v-)/2) is not just at a distance of 1e9 but
411 // at a distance of 1e8.
412 // The only exception is for the smallest normal: the largest denormal is
413 // at the same distance as its successor.
414 // Note: denormals have the same exponent as the smallest normals.
415 bool physical_significand_is_zero = ((AsUint32() & kSignificandMask) == 0);
416 return physical_significand_is_zero && (Exponent() != kDenormalExponent);
417 }

◆ NaN()

static float double_conversion::Single::NaN ( )
inlinestatic

Definition at line 425 of file ieee.h.

425 {
426 return Single(kNaN).value();
427 }

◆ NormalizedBoundaries()

void double_conversion::Single::NormalizedBoundaries ( DiyFp out_m_minus,
DiyFp out_m_plus 
) const
inline

Definition at line 383 of file ieee.h.

383 {
385 DiyFp v = this->AsDiyFp();
386 DiyFp m_plus = DiyFp::Normalize(DiyFp((v.f() << 1) + 1, v.e() - 1));
387 DiyFp m_minus;
388 if (LowerBoundaryIsCloser()) {
389 m_minus = DiyFp((v.f() << 2) - 1, v.e() - 2);
390 } else {
391 m_minus = DiyFp((v.f() << 1) - 1, v.e() - 1);
392 }
393 m_minus.set_f(m_minus.f() << (m_minus.e() - m_plus.e()));
394 m_minus.set_e(m_plus.e());
395 *out_m_plus = m_plus;
396 *out_m_minus = m_minus;
397 }
DiyFp AsDiyFp() const
Definition: ieee.h:302
bool LowerBoundaryIsCloser() const
Definition: ieee.h:406
float value() const
Definition: ieee.h:419

◆ Sign()

int double_conversion::Single::Sign ( ) const
inline

Definition at line 374 of file ieee.h.

374 {
375 uint32_t d32 = AsUint32();
376 return (d32 & kSignMask) == 0? 1: -1;
377 }
static const uint32_t kSignMask
Definition: ieee.h:288

◆ Significand()

uint32_t double_conversion::Single::Significand ( ) const
inline

Definition at line 322 of file ieee.h.

322 {
323 uint32_t d32 = AsUint32();
324 uint32_t significand = d32 & kSignificandMask;
325 if (!IsDenormal()) {
326 return significand + kHiddenBit;
327 } else {
328 return significand;
329 }
330 }
static const uint32_t kHiddenBit
Definition: ieee.h:291

◆ UpperBoundary()

DiyFp double_conversion::Single::UpperBoundary ( ) const
inline

Definition at line 401 of file ieee.h.

401 {
403 return DiyFp(Significand() * 2 + 1, Exponent() - 1);
404 }

◆ value()

float double_conversion::Single::value ( ) const
inline

Definition at line 419 of file ieee.h.

419{ return uint32_to_float(d32_); }
static float uint32_to_float(uint32_t d32)
Definition: ieee.h:39

Member Data Documentation

◆ kExponentMask

const uint32_t double_conversion::Single::kExponentMask = 0x7F800000
static

Definition at line 289 of file ieee.h.

◆ kHiddenBit

const uint32_t double_conversion::Single::kHiddenBit = 0x00800000
static

Definition at line 291 of file ieee.h.

◆ kPhysicalSignificandSize

const int double_conversion::Single::kPhysicalSignificandSize = 23
static

Definition at line 293 of file ieee.h.

◆ kQuietNanBit

const uint32_t double_conversion::Single::kQuietNanBit = 0x00400000
static

Definition at line 292 of file ieee.h.

◆ kSignificandMask

const uint32_t double_conversion::Single::kSignificandMask = 0x007FFFFF
static

Definition at line 290 of file ieee.h.

◆ kSignificandSize

const int double_conversion::Single::kSignificandSize = 24
static

Definition at line 294 of file ieee.h.

◆ kSignMask

const uint32_t double_conversion::Single::kSignMask = 0x80000000
static

Definition at line 288 of file ieee.h.


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