Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
double_conversion::UInt128 Class Reference

Public Member Functions

 UInt128 ()
 
 UInt128 (uint64_t high, uint64_t low)
 
void Multiply (uint32_t multiplicand)
 
void Shift (int shift_amount)
 
int DivModPowerOf2 (int power)
 
bool IsZero () const
 
int BitAt (int position) const
 

Detailed Description

Definition at line 37 of file fixed-dtoa.cc.

Constructor & Destructor Documentation

◆ UInt128() [1/2]

double_conversion::UInt128::UInt128 ( )
inline

Definition at line 39 of file fixed-dtoa.cc.

39: high_bits_(0), low_bits_(0) { }

◆ UInt128() [2/2]

double_conversion::UInt128::UInt128 ( uint64_t  high,
uint64_t  low 
)
inline

Definition at line 40 of file fixed-dtoa.cc.

40: high_bits_(high), low_bits_(low) { }

Member Function Documentation

◆ BitAt()

int double_conversion::UInt128::BitAt ( int  position) const
inline

Definition at line 101 of file fixed-dtoa.cc.

101 {
102 if (position >= 64) {
103 return static_cast<int>(high_bits_ >> (position - 64)) & 1;
104 } else {
105 return static_cast<int>(low_bits_ >> position) & 1;
106 }
107 }

◆ DivModPowerOf2()

int double_conversion::UInt128::DivModPowerOf2 ( int  power)
inline

Definition at line 82 of file fixed-dtoa.cc.

82 {
83 if (power >= 64) {
84 int result = static_cast<int>(high_bits_ >> (power - 64));
85 high_bits_ -= static_cast<uint64_t>(result) << (power - 64);
86 return result;
87 } else {
88 uint64_t part_low = low_bits_ >> power;
89 uint64_t part_high = high_bits_ << (64 - power);
90 int result = static_cast<int>(part_low + part_high);
91 high_bits_ = 0;
92 low_bits_ -= part_low << power;
93 return result;
94 }
95 }
GAsyncResult * result

◆ IsZero()

bool double_conversion::UInt128::IsZero ( ) const
inline

Definition at line 97 of file fixed-dtoa.cc.

97 {
98 return high_bits_ == 0 && low_bits_ == 0;
99 }

◆ Multiply()

void double_conversion::UInt128::Multiply ( uint32_t  multiplicand)
inline

Definition at line 42 of file fixed-dtoa.cc.

42 {
43 uint64_t accumulator;
44
45 accumulator = (low_bits_ & kMask32) * multiplicand;
46 uint32_t part = static_cast<uint32_t>(accumulator & kMask32);
47 accumulator >>= 32;
48 accumulator = accumulator + (low_bits_ >> 32) * multiplicand;
49 low_bits_ = (accumulator << 32) + part;
50 accumulator >>= 32;
51 accumulator = accumulator + (high_bits_ & kMask32) * multiplicand;
52 part = static_cast<uint32_t>(accumulator & kMask32);
53 accumulator >>= 32;
54 accumulator = accumulator + (high_bits_ >> 32) * multiplicand;
55 high_bits_ = (accumulator << 32) + part;
56 DOUBLE_CONVERSION_ASSERT((accumulator >> 32) == 0);
57 }
#define DOUBLE_CONVERSION_ASSERT(condition)
Definition: utils.h:46

◆ Shift()

void double_conversion::UInt128::Shift ( int  shift_amount)
inline

Definition at line 59 of file fixed-dtoa.cc.

59 {
60 DOUBLE_CONVERSION_ASSERT(-64 <= shift_amount && shift_amount <= 64);
61 if (shift_amount == 0) {
62 return;
63 } else if (shift_amount == -64) {
64 high_bits_ = low_bits_;
65 low_bits_ = 0;
66 } else if (shift_amount == 64) {
67 low_bits_ = high_bits_;
68 high_bits_ = 0;
69 } else if (shift_amount <= 0) {
70 high_bits_ <<= -shift_amount;
71 high_bits_ += low_bits_ >> (64 + shift_amount);
72 low_bits_ <<= -shift_amount;
73 } else {
74 low_bits_ >>= shift_amount;
75 low_bits_ += high_bits_ << (64 - shift_amount);
76 high_bits_ >>= shift_amount;
77 }
78 }

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