C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Low-level float parsing functions

From: Zhihao Yuan <zy_at_[hidden]>
Date: Wed, 30 Apr 2025 17:58:44 +0000
On Wednesday, April 30th, 2025 at 2:48 AM, Jan Schultke via Std-Proposals <std-proposals_at_[hidden]> wrote:

>

>

> The lowest-level interface could be taking byte spans containing the bits of the integer part and of the fraction. I suppose, the true level zero function would look like:
>

> parse_float_result
> parse_float(std::span<const unsigned char> integer, std::span<const unsigned char> fraction, int exponent, int base);
>

> [...]
> Also note that byte spans are needed because integers may not be large enough. For example, the architecture may have 128-bit floats, which require over 30 decimal digits, far more than a 64-bit integer could provide.

Then use _BitInt(K). The goal of going low-level
in floating point parsing should be no parse,
exchanging mantissa and exponent in decimal,
plus any necessary information. That is the same
for a lower-level std::to_char, where the key is not
to format.

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
_______________________________________________

Received on 2025-04-30 17:58:52