Date: Mon, 28 Apr 2025 14:20:18 -0700
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?
> 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:20:23