Flutter Engine
The Flutter Engine
Classes | Functions | Variables
double_conversion::PowersOfTenCache Namespace Reference

Classes

struct  CachedPower
 

Functions

void GetCachedPowerForBinaryExponentRange (int min_exponent, int max_exponent, DiyFp *power, int *decimal_exponent)
 
void GetCachedPowerForDecimalExponent (int requested_exponent, DiyFp *power, int *found_exponent)
 

Variables

static const CachedPower kCachedPowers []
 
static const int kCachedPowersOffset = 348
 
static const double kD_1_LOG2_10 = 0.30102999566398114
 
static const int kDecimalExponentDistance = 8
 
static const int kMinDecimalExponent = -348
 
static const int kMaxDecimalExponent = 340
 

Function Documentation

◆ GetCachedPowerForBinaryExponentRange()

void double_conversion::PowersOfTenCache::GetCachedPowerForBinaryExponentRange ( int  min_exponent,
int  max_exponent,
DiyFp power,
int decimal_exponent 
)

Definition at line 139 of file cached-powers.cc.

143 {
144 int kQ = DiyFp::kSignificandSize;
145 double k = ceil((min_exponent + kQ - 1) * kD_1_LOG2_10);
146 int foo = kCachedPowersOffset;
147 int index =
148 (foo + static_cast<int>(k) - 1) / kDecimalExponentDistance + 1;
149 DOUBLE_CONVERSION_ASSERT(0 <= index && index < static_cast<int>(DOUBLE_CONVERSION_ARRAY_SIZE(kCachedPowers)));
150 CachedPower cached_power = kCachedPowers[index];
151 DOUBLE_CONVERSION_ASSERT(min_exponent <= cached_power.binary_exponent);
152 (void) max_exponent; // Mark variable as used.
153 DOUBLE_CONVERSION_ASSERT(cached_power.binary_exponent <= max_exponent);
154 *decimal_exponent = cached_power.decimal_exponent;
155 *power = DiyFp(cached_power.significand, cached_power.binary_exponent);
156}
static const int kDecimalExponentDistance
Definition: cached-powers.h:39
static const CachedPower kCachedPowers[]
SIN Vec< N, float > ceil(const Vec< N, float > &x)
Definition: SkVx.h:702
#define DOUBLE_CONVERSION_ASSERT(condition)
Definition: utils.h:46
#define DOUBLE_CONVERSION_ARRAY_SIZE(a)
Definition: utils.h:205

◆ GetCachedPowerForDecimalExponent()

void double_conversion::PowersOfTenCache::GetCachedPowerForDecimalExponent ( int  requested_exponent,
DiyFp power,
int found_exponent 
)

Definition at line 159 of file cached-powers.cc.

161 {
162 DOUBLE_CONVERSION_ASSERT(kMinDecimalExponent <= requested_exponent);
164 int index =
165 (requested_exponent + kCachedPowersOffset) / kDecimalExponentDistance;
166 CachedPower cached_power = kCachedPowers[index];
167 *power = DiyFp(cached_power.significand, cached_power.binary_exponent);
168 *found_exponent = cached_power.decimal_exponent;
169 DOUBLE_CONVERSION_ASSERT(*found_exponent <= requested_exponent);
170 DOUBLE_CONVERSION_ASSERT(requested_exponent < *found_exponent + kDecimalExponentDistance);
171}

Variable Documentation

◆ kCachedPowers

const CachedPower double_conversion::PowersOfTenCache::kCachedPowers[]
static

Definition at line 46 of file cached-powers.cc.

◆ kCachedPowersOffset

const int double_conversion::PowersOfTenCache::kCachedPowersOffset = 348
static

Definition at line 136 of file cached-powers.cc.

◆ kD_1_LOG2_10

const double double_conversion::PowersOfTenCache::kD_1_LOG2_10 = 0.30102999566398114
static

Definition at line 137 of file cached-powers.cc.

◆ kDecimalExponentDistance

const int double_conversion::PowersOfTenCache::kDecimalExponentDistance = 8
static

Definition at line 39 of file cached-powers.h.

◆ kMaxDecimalExponent

const int double_conversion::PowersOfTenCache::kMaxDecimalExponent = 340
static

Definition at line 42 of file cached-powers.h.

◆ kMinDecimalExponent

const int double_conversion::PowersOfTenCache::kMinDecimalExponent = -348
static

Definition at line 41 of file cached-powers.h.