[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAHp75Vffgz7mc4Z_KibtuuVCvBfVEYPG0iEPBXrEFzYkaymGKA@mail.gmail.com>
Date: Tue, 13 Jan 2026 08:49:53 +0200
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Jonathan Santos <jonath4nns@...il.com>
Cc: Jonathan Cameron <jic23@...nel.org>, Jonathan Santos <Jonathan.Santos@...log.com>,
linux-iio@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, lars@...afoo.de, Michael.Hennerich@...log.com,
dlechner@...libre.com, nuno.sa@...log.com, andy@...nel.org, robh@...nel.org,
krzk+dt@...nel.org, conor+dt@...nel.org
Subject: Re: [PATCH v5 3/5] units: add PERCENT and BASIS_POINTS macros
On Tue, Jan 13, 2026 at 5:32 AM Jonathan Santos <jonath4nns@...il.com> wrote:
> On 12/27, Andy Shevchenko wrote:
> > On Sat, Dec 27, 2025 at 5:55 PM Jonathan Cameron <jic23@...nel.org> wrote:
> > > On Wed, 17 Dec 2025 02:52:45 -0300
> > > Jonathan Santos <Jonathan.Santos@...log.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.
My comment was more about the prefix (PER) and the naming (not
BASIS_POINTS, but something from PER*), and for the comprehension I
would rather see all three defined (pp is _not_ part of these as you
mentioned its semantics is different).
> 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.
Sounds good at the first glance.
> > > > + */
> > > > +#define PERCENT 100UL
> > > > +#define BASIS_POINTS 10000UL
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists