Date: Mon, 28 Apr 2025 21:25:21 +0000
You could.
But you can also just pass in the offset of where the decimal separator supposed to be, and it does the same job and you don't need to touch the mantissa.
I haven't settled on a final design yet, I'm still trying out what works best.
-----Original Message-----
From: Thiago Macieira <thiago_at_macieira.org>
Sent: Monday, April 28, 2025 11:20 PM
To: std-proposals_at_[hidden]; Tiago Freire <tmiguelf_at_hotmail.com>
Subject: Re: [std-proposals] Low-level float parsing functions
On Monday, 28 April 2025 14:14:02 Pacific Daylight Time Tiago Freire wrote:
> An alternative implementation that I'm currently working that uses the
> "digits" concept would be able to bypass this limitation, but would
> require copying data to a temporary buffer for processing. However,
> this is not a significant issue, you only need a maximum of 18
> non-leading 0 digits in order to completely decode a double (and a
> maximum of 3 exponent digits), any digits after that are irrelevant
> and contribute nothing to the final result. You can fit that quite
> comfortably on the stack. And it is relatively easy to write an
> algorithm that only gets those 18 non-leading 0 digits and discard the
> rest (only confirming that they are indeed valid numbers to deal with
> the possibility that the text doesn't actually encode a number).
Sure, but you need to adjust the exponent too, in which case you probably want to pass it as a pre-parsed integer instead of text.
In fact, why not pass the mantissa as number too, seeing as you've practically decoded it anyway?
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Principal Engineer - Intel DCAI Platform & System Engineering
But you can also just pass in the offset of where the decimal separator supposed to be, and it does the same job and you don't need to touch the mantissa.
I haven't settled on a final design yet, I'm still trying out what works best.
-----Original Message-----
From: Thiago Macieira <thiago_at_macieira.org>
Sent: Monday, April 28, 2025 11:20 PM
To: std-proposals_at_[hidden]; Tiago Freire <tmiguelf_at_hotmail.com>
Subject: Re: [std-proposals] Low-level float parsing functions
On Monday, 28 April 2025 14:14:02 Pacific Daylight Time Tiago Freire wrote:
> An alternative implementation that I'm currently working that uses the
> "digits" concept would be able to bypass this limitation, but would
> require copying data to a temporary buffer for processing. However,
> this is not a significant issue, you only need a maximum of 18
> non-leading 0 digits in order to completely decode a double (and a
> maximum of 3 exponent digits), any digits after that are irrelevant
> and contribute nothing to the final result. You can fit that quite
> comfortably on the stack. And it is relatively easy to write an
> algorithm that only gets those 18 non-leading 0 digits and discard the
> rest (only confirming that they are indeed valid numbers to deal with
> the possibility that the text doesn't actually encode a number).
Sure, but you need to adjust the exponent too, in which case you probably want to pass it as a pre-parsed integer instead of text.
In fact, why not pass the mantissa as number too, seeing as you've practically decoded it anyway?
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Principal Engineer - Intel DCAI Platform & System Engineering
Received on 2025-04-28 21:25:27