[KongchangAI]
Concept

strtod

A general-purpose function in the C standard library (<stdlib.h>) that parses a string into a double. It must handle edge cases including signs, whitespace, decimal and scientific notation, inf/nan, and localized decimal points, following the C standard and IEEE 754 rounding requirements.

Timeline (last 90 days)

Nov 8

In the initial implementation, the parse_number performance of the Rust extension was actually faster than the C extension, because the parsing function in the Rust standard library equivalent to C's strtod is about twice as fast as strtod.

Unverified50%
Nov 8

The custom C parser reduced decimal parsing from 106 ns to 18 ns, because the input domain of parse_number was narrowed (it only needs to strip currency symbols, thousands separators, and percent signs), allowing it to skip the branching and validation overhead that strtod pays for generality.

Unverified50%
Oct 12

The C standard library provides the strtod, strtof, and strtold functions to perform string-to-floating-point conversion.

Unverified50%
Oct 12

According to the standard, strtod should set errno to ERANGE when the conversion result overflows or underflows.

Unverified50%
Oct 12

The endptr parameter points to the position where conversion stopped; if it equals the starting position of the input string, it indicates that no characters were successfully converted.

Unverified50%

All Facts (5)

Source Articles