Numbers with a fractional or exponent part are a distinct type. Today you tell a float apart from an integer and parse it, so a config can hold measurements and ratios.
Parse floats with a fractional part, an exponent, or both.
A float is a number with a fractional part, an exponent, or both: 3.14,
-2.5, 1e6 (a million), 6.022e23. The presence of a decimal point . or an
exponent marker e/E is exactly what separates a float from an integer, so the
classification is a quick scan of the bare numeric token before you parse it. A
token with neither stays on the integer path from the earlier lessons.
The same readability rules carry over: an optional leading sign, and underscores
between digits in both the whole and fractional parts. TOML requires digits on
both sides of the decimal point - 3.14, never .14 or 3. - and an exponent may
carry its own sign (1e-9). Store the result as a 64-bit floating-point value; that
matches how TOML defines floats and how nearly every consumer will use them. Telling
the two number types apart cleanly, then handing the float text to a float parse, is
today’s step.
// classify the bare numeric token before parsing:// contains '.' or 'e'/'E' (after the optional sign) -> float// otherwise -> integer (the earlier path)// strip inter-digit underscores, parse as a 64-bit float