[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251227155525.6d712f42@jic23-huawei>
Date: Sat, 27 Dec 2025 15:55:25 +0000
From: Jonathan Cameron <jic23@...nel.org>
To: Jonathan Santos <Jonathan.Santos@...log.com>
Cc: <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>, <jonath4nns@...il.com>
Subject: Re: [PATCH v5 3/5] units: add PERCENT and BASIS_POINTS macros
On Wed, 17 Dec 2025 02:52:45 -0300
Jonathan Santos <Jonathan.Santos@...log.com> wrote:
> Add macros for percentage related units, with basis points defined as
> 1/100th of a percent. Basis points are commonly used in finance and
> engineering to express small percentage changes with precision.
>
> Signed-off-by: Jonathan Santos <Jonathan.Santos@...log.com>
> ---
> v5 Changes:
> * Included PERCENT macro along with BASIS_POINTS.
> * Adjusted commit description and comment in the code to add more context and
> examples.
>
> v4 Changes:
> * New patch.
> ---
> include/linux/units.h | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/include/linux/units.h b/include/linux/units.h
> index 00e15de33eca..9c2fbcf04c81 100644
> --- a/include/linux/units.h
> +++ b/include/linux/units.h
> @@ -21,6 +21,20 @@
> #define PICO 1000000000000ULL
> #define FEMTO 1000000000000000ULL
>
> +/*
> + * 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?
> + */
> +#define PERCENT 100UL
> +#define BASIS_POINTS 10000UL
> +
> #define NANOHZ_PER_HZ 1000000000UL
> #define MICROHZ_PER_HZ 1000000UL
> #define MILLIHZ_PER_HZ 1000UL
Powered by blists - more mailing lists