Re: [PATCH v5 1/7] lib: kstrtox: support E notation in kstrtoudec64() and kstrtodec64()
From: Jonathan Cameron
Date: Sat Nov 07 2026 - 18:47:10 EST
On Tue, 3 Nov 2026 19:51:40 +0200
Andy Shevchenko <andriy.shevchenko@xxxxxxxxx> wrote:
> On Mon, Nov 02, 2026 at 07:40:59AM -0300, Rodrigo Alencar via B4 Relay wrote:
> >
> > Allow decimal strings to carry an exponent suffix, such as "2.7e10" or
> > "271828e-5", in kstrtoudec64() and kstrtodec64(). The exponent is added
> > to the requested scale to work out how many integer and fractional digits
> > are consumed. A negative effective exponent drops integer digits.
> >
> > The digits are now scanned first and the string termination is checked
> > before any conversion. A missing or malformed exponent ("1e", "1e+")
> > returns -EINVAL. An exponent that overflows when added to the scale, or
> > that makes the result exceed 64 bits, returns -ERANGE.
>
> ...
>
> > +static int skip_digits(const char **s)
>
> In case we need a new version, the skip_and_count_digits() fits better.
>
Agreed. Given we aren't pressed for time this cycle, let us
do that change and add the bit of extra commit message to patch 2.
This is really nice feature, so worth a bit of extra polishing!
Jonathan
> > +{
> > + const char *start = *s;
> > +
> > + while (isdigit(**s))
> > + (*s)++;
> > +
> > + return *s - start;
> > +}
>