From: David Laight <david.laight.linux@gmail.com>
To: Rodrigo Alencar <455.rodrigo.alencar@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@intel.com>,
rodrigo.alencar@analog.com, linux-kernel@vger.kernel.org,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-doc@vger.kernel.org, Jonathan Cameron <jic23@kernel.org>,
David Lechner <dlechner@baylibre.com>,
Andy Shevchenko <andy@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Jonathan Corbet <corbet@lwn.net>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v8 02/10] lib: kstrtox: add kstrntoull() helper
Date: Fri, 20 Mar 2026 14:44:59 +0000 [thread overview]
Message-ID: <20260320144459.705c8e60@pumpkin> (raw)
In-Reply-To: <qsquhriyrepndxwexox35oi5i7v4klb64lajuk3j3pfozkjiew@fp55l4znck4o>
On Fri, 20 Mar 2026 12:41:57 +0000
Rodrigo Alencar <455.rodrigo.alencar@gmail.com> wrote:
...
> > Some (stupid) thoughts loudly. IIUC even if we implement '%g' in scanf(), it
> > wont help you as you want to have more precise values. Do I get it correct?
>
> If I am parsing 3.14159265359 with 6 decimal precision I want to stop at:
>
> frac = 141592
> int = 3
>
> and ignore the rest.
>
If you add an 'upper limit' parameter and return a pointer to the digit
that exceeds the limit (which would normally get processed as a syntax error)
then you could have:
int_part = strtoull(pi, &end, ~0ull, 10);
if (end[0] == '.' && isdigit(end[1])) {
frac = strtoull(end + 2, &end, 999999, 10);
while (isdigit(*end))
end++;
}
Passing in the limit should help strtol() are strtoi() as well.
David
next prev parent reply other threads:[~2026-03-20 14:45 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 13:27 [PATCH v8 00/10] ADF41513/ADF41510 PLL frequency synthesizers Rodrigo Alencar
2026-03-03 13:27 ` Rodrigo Alencar via B4 Relay
2026-03-03 13:27 ` [PATCH v8 01/10] dt-bindings: iio: frequency: add adf41513 Rodrigo Alencar
2026-03-03 13:27 ` Rodrigo Alencar via B4 Relay
2026-03-03 13:27 ` [PATCH v8 02/10] lib: kstrtox: add kstrntoull() helper Rodrigo Alencar
2026-03-03 13:27 ` Rodrigo Alencar via B4 Relay
2026-03-03 13:49 ` Andy Shevchenko
2026-03-03 14:16 ` Rodrigo Alencar
2026-03-04 10:02 ` Rodrigo Alencar
2026-03-20 11:16 ` Rodrigo Alencar
2026-03-20 11:50 ` Andy Shevchenko
2026-03-20 12:08 ` Rodrigo Alencar
2026-03-20 12:24 ` Andy Shevchenko
2026-03-20 12:41 ` Rodrigo Alencar
2026-03-20 14:17 ` Andy Shevchenko
2026-03-20 14:44 ` David Laight [this message]
2026-03-04 10:16 ` David Laight
2026-03-04 11:41 ` Rodrigo Alencar
2026-03-10 9:26 ` Rodrigo Alencar
2026-03-10 10:50 ` David Laight
2026-03-10 11:30 ` Rodrigo Alencar
2026-03-03 13:27 ` [PATCH v8 03/10] lib: test-kstrtox: add tests for kstrntoull() Rodrigo Alencar
2026-03-03 13:27 ` Rodrigo Alencar via B4 Relay
2026-03-03 13:27 ` [PATCH v8 04/10] iio: core: add fixed point parsing with 64-bit parts Rodrigo Alencar
2026-03-03 13:27 ` Rodrigo Alencar via B4 Relay
2026-03-03 13:27 ` [PATCH v8 05/10] iio: test: add kunit test for fixed-point parsing Rodrigo Alencar
2026-03-03 13:27 ` Rodrigo Alencar via B4 Relay
2026-03-03 13:27 ` [PATCH v8 06/10] iio: frequency: adf41513: driver implementation Rodrigo Alencar
2026-03-03 13:27 ` Rodrigo Alencar via B4 Relay
2026-03-03 13:27 ` [PATCH v8 07/10] iio: frequency: adf41513: handle LE synchronization feature Rodrigo Alencar
2026-03-03 13:27 ` Rodrigo Alencar via B4 Relay
2026-03-03 13:27 ` [PATCH v8 08/10] iio: frequency: adf41513: features on frequency change Rodrigo Alencar
2026-03-03 13:27 ` Rodrigo Alencar via B4 Relay
2026-03-03 13:27 ` [PATCH v8 09/10] docs: iio: add documentation for adf41513 driver Rodrigo Alencar
2026-03-03 13:27 ` Rodrigo Alencar via B4 Relay
2026-03-03 13:27 ` [PATCH v8 10/10] Documentation: ABI: testing: add common ABI file for iio/frequency Rodrigo Alencar
2026-03-03 13:27 ` 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=20260320144459.705c8e60@pumpkin \
--to=david.laight.linux@gmail.com \
--cc=455.rodrigo.alencar@gmail.com \
--cc=Michael.Hennerich@analog.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=corbet@lwn.net \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-doc@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.