Thread (13 messages) 13 messages, 4 authors, 2026-01-13
STALE179d
Revisions (5)
  1. v1 [diff vs current]
  2. v3 [diff vs current]
  3. v4 [diff vs current]
  4. v5 current
  5. v6 [diff vs current]

[PATCH v5 3/5] units: add PERCENT and BASIS_POINTS macros

From: Jonathan Santos <hidden>
Date: 2025-12-17 12:43:32
Also in: linux-iio, lkml
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help