From: Jonathan Santos <jonath4nns@gmail.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
Jonathan Santos <Jonathan.Santos@analog.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, lars@metafoo.de,
Michael.Hennerich@analog.com, dlechner@baylibre.com,
nuno.sa@analog.com, andy@kernel.org, robh@kernel.org,
krzk+dt@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v5 3/5] units: add PERCENT and BASIS_POINTS macros
Date: Sat, 10 Jan 2026 23:11:55 -0300 [thread overview]
Message-ID: <aWMG6+ORRTy4ll8d@JSANTO12-L01.ad.analog.com> (raw)
In-Reply-To: <CAHp75Vd0n+aTkdzMC53y9LrPW4t0mckpzmmud4Ez5gXbAdLeVg@mail.gmail.com>
On 12/27, Andy Shevchenko wrote:
> On Sat, Dec 27, 2025 at 5:55 PM Jonathan Cameron <jic23@kernel.org> wrote:
> > On Wed, 17 Dec 2025 02:52:45 -0300
> > Jonathan Santos <Jonathan.Santos@analog.com> wrote:
>
> ...
>
> > > +/*
> > > + * Percentage and basis point units
> > > + *
> > > + * Basis points are 1/100th of a percent (1/100), commonly used in finance,
> > > + * engineering or other applications that require precise percentage
> > > + * calculations.
> > > + *
> > > + * Examples:
> > > + * 100% = 10000 basis points = BASIS_POINTS
> > > + * 1% = 100 basis points = PERCENT
> >
> > I don't understand the final equality in these examples.
> > The top line is as it says 10000 basis points but you have it equal
> > to BASIS_POINTS?
>
> Also there are pp (percentage points) and others like per mille
>
> https://en.wikipedia.org/wiki/Percentage_point (see "Related units" section).
>
Hi, Andy. Thanks for the suggestions,but I am still questioning how
the percentage points would be implemented, since it is defined as the
difference between two percentages and we cannot use floating points.
Also, should we keep this approach of unit conversion?
Example:
value / PERCENT -> converts a value from percent to ratio
value * PERCENT -> converts a value from ratio to percent
Just to make sure it is consistent with the rest.
> > > + */
> > > +#define PERCENT 100UL
> > > +#define BASIS_POINTS 10000UL
>
>
> --
> With Best Regards,
> Andy Shevchenko
next prev parent reply other threads:[~2026-01-13 3:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-17 5:52 [PATCH v5 0/5] Add support for ADAQ776x-1 ADC Family Jonathan Santos
2025-12-17 5:52 ` [PATCH v5 1/5] dt-bindings: iio: adc: ad7768-1: add new supported parts Jonathan Santos
2025-12-17 5:52 ` [PATCH v5 2/5] iio: adc: ad7768-1: introduce chip info for future multidevice support Jonathan Santos
2025-12-17 5:52 ` [PATCH v5 3/5] units: add PERCENT and BASIS_POINTS macros Jonathan Santos
2025-12-27 15:55 ` Jonathan Cameron
2025-12-27 16:48 ` Andy Shevchenko
2025-12-27 16:52 ` Andy Shevchenko
2025-12-27 16:53 ` Andy Shevchenko
2026-01-11 2:11 ` Jonathan Santos [this message]
2026-01-13 6:49 ` Andy Shevchenko
2025-12-17 5:52 ` [PATCH v5 4/5] iio: adc: ad7768-1: refactor ad7768_write_raw() Jonathan Santos
2025-12-17 5:53 ` [PATCH v5 5/5] iio: adc: ad7768-1: add support for ADAQ776x-1 ADC Family Jonathan Santos
2025-12-27 16:11 ` Jonathan Cameron
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=aWMG6+ORRTy4ll8d@JSANTO12-L01.ad.analog.com \
--to=jonath4nns@gmail.com \
--cc=Jonathan.Santos@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy.shevchenko@gmail.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/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®