From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: rodrigo.alencar@analog.com
Cc: linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Jonathan Cameron <jic23@kernel.org>,
David Lechner <dlechner@baylibre.com>,
Andy Shevchenko <andy@kernel.org>
Subject: Re: [PATCH v5 1/7] lib: kstrtox: support E notation in kstrtoudec64() and kstrtodec64()
Date: Tue, 3 Nov 2026 19:51:40 +0200 [thread overview]
Message-ID: <auofLF8TivwJiMwT@ashevche-desk.local> (raw)
In-Reply-To: <20261102-e-notation-v5-1-d399e544a982@analog.com>
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.
> +{
> + const char *start = *s;
> +
> + while (isdigit(**s))
> + (*s)++;
> +
> + return *s - start;
> +}
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-11-03 17:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 10:40 [PATCH v5 0/7] Add E notation support to kstrtodec64() and IIO sysfs writes Rodrigo Alencar via B4 Relay
2026-11-02 10:40 ` [PATCH v5 1/7] lib: kstrtox: support E notation in kstrtoudec64() and kstrtodec64() Rodrigo Alencar via B4 Relay
2026-11-03 17:51 ` Andy Shevchenko [this message]
2026-11-02 10:41 ` [PATCH v5 2/7] lib: kstrtox: round to nearest, ties to even in kstrto[u]dec64() Rodrigo Alencar via B4 Relay
2026-11-03 17:55 ` Andy Shevchenko
2026-11-02 10:41 ` [PATCH v5 3/7] lib: kstrtox: allow a negative scale " Rodrigo Alencar via B4 Relay
2026-11-02 10:41 ` [PATCH v5 4/7] lib: test-kstrtox: add E notation tests for kstrto[u]dec64() Rodrigo Alencar via B4 Relay
2026-11-02 10:41 ` [PATCH v5 5/7] iio: test: rescale: compare scales against the precision of the output Rodrigo Alencar via B4 Relay
2026-11-02 10:41 ` [PATCH v5 6/7] iio: core: use kstrtodec64() to parse fixed-point values Rodrigo Alencar via B4 Relay
2026-11-02 10:41 ` [PATCH v5 7/7] iio: test: add kunit tests for channel info writes Rodrigo Alencar via B4 Relay
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=auofLF8TivwJiMwT@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=akpm@linux-foundation.org \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rodrigo.alencar@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®