Module

std::float

source

Floating-point numbers from text. They are read through C's strtod, which rounds a decimal to the nearest double correctly (ties to even) and to an infinity past the largest one. The view is read through whatever capability permits it (Exclusive!, Shared!, StaticRead).

Functions

parse_f64The double that all of bytes spells, as strtod reads it in the C locale: a decimal such as -2.5e3 or .5, a hexadecimal float such as 0x1p-3, inf or nan.

Function declarations

fn parse_f64source

forall C, S where ReadBytes[C, S], Copy[S].
fn parse_f64(&cx: C, bytes: S) -> Option[f64] { ... }

The double that all of bytes spells, as strtod reads it in the C locale: a decimal such as -2.5e3 or .5, a hexadecimal float such as 0x1p-3, inf or nan. Nothing for an empty view, a leading space, or any byte past the number (a NUL among them).

A process starts in the C locale and the library never changes it, so the decimal point is .; foreign code that calls setlocale (for LC_NUMERIC) changes what strtod reads, and calling it while another thread parses here is a data race in C.