C++ Logo

std-proposals

Advanced search

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

From: Tiago Freire <tmiguelf_at_[hidden]>
Date: Mon, 28 Apr 2025 14:42:13 +0000
Kind of like that?
https://github.com/tmiguelf/utilities/blob/345421be243b7b6a6e70988a77422b5a0b1fe0a1/CoreLib/include/CoreLib/string/core_fp_charconv.hpp#L155


________________________________
From: Std-Proposals <std-proposals-bounces_at_[hidden]> on behalf of Jan Schultke via Std-Proposals <std-proposals_at_[hidden]>
Sent: Monday, April 28, 2025 4:36:31 PM
To: std-proposals_at_[hidden] <std-proposals_at_[hidden]>
Cc: Jan Schultke <janschultke_at_[hidden]>
Subject: Re: [std-proposals] Low-level float parsing functions

To clarify the Ada example, Ada hex floats would look like "16#F.FF#E+2", so to parse it, rather than "just doing it", you would need to build a new string with 16# and and the # before E removed, and then std::from_chars can accept it.

However, you need a brand new buffer to do this (assuming that your parse function takes a string_view or something), and as I've said, that may be tricky. By the time you've parsed the number, you already know where the integer, fractional, and exponent digits are anyway, so your life would be a lot easier if you could "just do it" at that point instead of doing a pointless ritual to make std::from_chars happy.


Received on 2025-04-28 14:42:21