OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <limits.h> | 5 #include <limits.h> |
6 #include <stdarg.h> | 6 #include <stdarg.h> |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "include/v8stdint.h" | 9 #include "include/v8stdint.h" |
10 #include "src/base/logging.h" | 10 #include "src/base/logging.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 {V8_2PART_UINT64_C(0x80444b5e, 7aa7cf85), 907, 292}, | 104 {V8_2PART_UINT64_C(0x80444b5e, 7aa7cf85), 907, 292}, |
105 {V8_2PART_UINT64_C(0xbf21e440, 03acdd2d), 933, 300}, | 105 {V8_2PART_UINT64_C(0xbf21e440, 03acdd2d), 933, 300}, |
106 {V8_2PART_UINT64_C(0x8e679c2f, 5e44ff8f), 960, 308}, | 106 {V8_2PART_UINT64_C(0x8e679c2f, 5e44ff8f), 960, 308}, |
107 {V8_2PART_UINT64_C(0xd433179d, 9c8cb841), 986, 316}, | 107 {V8_2PART_UINT64_C(0xd433179d, 9c8cb841), 986, 316}, |
108 {V8_2PART_UINT64_C(0x9e19db92, b4e31ba9), 1013, 324}, | 108 {V8_2PART_UINT64_C(0x9e19db92, b4e31ba9), 1013, 324}, |
109 {V8_2PART_UINT64_C(0xeb96bf6e, badf77d9), 1039, 332}, | 109 {V8_2PART_UINT64_C(0xeb96bf6e, badf77d9), 1039, 332}, |
110 {V8_2PART_UINT64_C(0xaf87023b, 9bf0ee6b), 1066, 340}, | 110 {V8_2PART_UINT64_C(0xaf87023b, 9bf0ee6b), 1066, 340}, |
111 }; | 111 }; |
112 | 112 |
113 #ifdef DEBUG | 113 #ifdef DEBUG |
114 static const int kCachedPowersLength = ARRAY_SIZE(kCachedPowers); | 114 static const int kCachedPowersLength = arraysize(kCachedPowers); |
115 #endif | 115 #endif |
116 | 116 |
117 static const int kCachedPowersOffset = 348; // -1 * the first decimal_exponent. | 117 static const int kCachedPowersOffset = 348; // -1 * the first decimal_exponent. |
118 static const double kD_1_LOG2_10 = 0.30102999566398114; // 1 / lg(10) | 118 static const double kD_1_LOG2_10 = 0.30102999566398114; // 1 / lg(10) |
119 // Difference between the decimal exponents in the table above. | 119 // Difference between the decimal exponents in the table above. |
120 const int PowersOfTenCache::kDecimalExponentDistance = 8; | 120 const int PowersOfTenCache::kDecimalExponentDistance = 8; |
121 const int PowersOfTenCache::kMinDecimalExponent = -348; | 121 const int PowersOfTenCache::kMinDecimalExponent = -348; |
122 const int PowersOfTenCache::kMaxDecimalExponent = 340; | 122 const int PowersOfTenCache::kMaxDecimalExponent = 340; |
123 | 123 |
124 void PowersOfTenCache::GetCachedPowerForBinaryExponentRange( | 124 void PowersOfTenCache::GetCachedPowerForBinaryExponentRange( |
(...skipping 25 matching lines...) Expand all Loading... |
150 int index = | 150 int index = |
151 (requested_exponent + kCachedPowersOffset) / kDecimalExponentDistance; | 151 (requested_exponent + kCachedPowersOffset) / kDecimalExponentDistance; |
152 CachedPower cached_power = kCachedPowers[index]; | 152 CachedPower cached_power = kCachedPowers[index]; |
153 *power = DiyFp(cached_power.significand, cached_power.binary_exponent); | 153 *power = DiyFp(cached_power.significand, cached_power.binary_exponent); |
154 *found_exponent = cached_power.decimal_exponent; | 154 *found_exponent = cached_power.decimal_exponent; |
155 DCHECK(*found_exponent <= requested_exponent); | 155 DCHECK(*found_exponent <= requested_exponent); |
156 DCHECK(requested_exponent < *found_exponent + kDecimalExponentDistance); | 156 DCHECK(requested_exponent < *found_exponent + kDecimalExponentDistance); |
157 } | 157 } |
158 | 158 |
159 } } // namespace v8::internal | 159 } } // namespace v8::internal |
OLD | NEW |