lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <43504217d5b3c32da946bed0ce4d81e216f7c7c7.1765900411.git.Jonathan.Santos@analog.com>
Date: Wed, 17 Dec 2025 02:52:45 -0300
From: Jonathan Santos <Jonathan.Santos@...log.com>
To: <linux-iio@...r.kernel.org>, <devicetree@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>
CC: Jonathan Santos <Jonathan.Santos@...log.com>, <lars@...afoo.de>,
        <Michael.Hennerich@...log.com>, <jic23@...nel.org>,
        <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: [PATCH v5 3/5] units: add PERCENT and BASIS_POINTS macros

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
+ */
+#define PERCENT		100UL
+#define BASIS_POINTS	10000UL
+
 #define NANOHZ_PER_HZ		1000000000UL
 #define MICROHZ_PER_HZ		1000000UL
 #define MILLIHZ_PER_HZ		1000UL
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ