MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / StrtodFullPrecision

Function StrtodFullPrecision

rapidjson/internal/strtod.h:224–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222}
223
224inline double StrtodFullPrecision(double d, int p, const char* decimals, size_t length, size_t decimalPosition, int exp) {
225 RAPIDJSON_ASSERT(d >= 0.0);
226 RAPIDJSON_ASSERT(length >= 1);
227
228 double result;
229 if (StrtodFast(d, p, &result))
230 return result;
231
232 // Trim leading zeros
233 while (*decimals == '0' && length > 1) {
234 length--;
235 decimals++;
236 decimalPosition--;
237 }
238
239 // Trim trailing zeros
240 while (decimals[length - 1] == '0' && length > 1) {
241 length--;
242 decimalPosition--;
243 exp++;
244 }
245
246 // Trim right-most digits
247 const int kMaxDecimalDigit = 780;
248 if (static_cast<int>(length) > kMaxDecimalDigit) {
249 int delta = (static_cast<int>(length) - kMaxDecimalDigit);
250 exp += delta;
251 decimalPosition -= static_cast<unsigned>(delta);
252 length = kMaxDecimalDigit;
253 }
254
255 // If too small, underflow to zero
256 if (int(length) + exp < -324)
257 return 0.0;
258
259 if (StrtodDiyFp(decimals, length, decimalPosition, exp, &result))
260 return result;
261
262 // Use approximation from StrtodDiyFp and make adjustment with BigInteger comparison
263 return StrtodBigInteger(result, decimals, length, decimalPosition, exp);
264}
265
266} // namespace internal
267RAPIDJSON_NAMESPACE_END

Callers 1

ParseNumberMethod · 0.85

Calls 3

StrtodFastFunction · 0.85
StrtodDiyFpFunction · 0.85
StrtodBigIntegerFunction · 0.85

Tested by

no test coverage detected