Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

units: add conversion macros for percentage related units

Add macros to convert between ratio and percentage related units,
including percent (1/100), permille (1/1,000), permyriad (1/10,000,
also equivalent to one Basis point) and per cent mille (1/100,000).
Those are Used for precise fractional calculations in engineering,
finance, and measurement applications.

Signed-off-by: Jonathan Santos <Jonathan.Santos@analog.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Jonathan Santos and committed by
Jonathan Cameron
404a3b4c fa087f5b

+19
+19
include/linux/units.h
··· 21 21 #define PICO 1000000000000ULL 22 22 #define FEMTO 1000000000000000ULL 23 23 24 + /* 25 + * Percentage and related scaling units 26 + * 27 + * These macros define scaling factors used to convert between ratio and 28 + * percentage-based representations with different decimal resolutions. 29 + * They are used for precise fractional calculations in engineering, finance, 30 + * and measurement applications. 31 + * 32 + * Examples: 33 + * 1% = 0.01 = 1 / PERCENT 34 + * 0.1% = 0.001 = 1 / PERMILLE 35 + * 0.01% = 0.0001 = 1 / PERMYRIAD (1 basis point) 36 + * 0.001% = 0.00001 = 1 / PERCENTMILLE 37 + */ 38 + #define PERCENT 100 39 + #define PERMILLE 1000 40 + #define PERMYRIAD 10000 41 + #define PERCENTMILLE 100000 42 + 24 43 #define NANOHZ_PER_HZ 1000000000UL 25 44 #define MICROHZ_PER_HZ 1000000UL 26 45 #define MILLIHZ_PER_HZ 1000UL