diff options
Diffstat (limited to 'include/common.h')
-rw-r--r-- | include/common.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/include/common.h b/include/common.h index 03e1b19d55..373663ea88 100644 --- a/include/common.h +++ b/include/common.h @@ -218,8 +218,22 @@ /* There isn't really a better place for this */ #define C_TO_K(temp_c) ((temp_c) + 273) #define K_TO_C(temp_c) ((temp_c) - 273) -#define CELSIUS_TO_DECI_KELVIN(temp_c) ((temp_c) * 10 + 2731) -#define DECI_KELVIN_TO_CELSIUS(temp_dk) ((temp_dk - 2731) / 10) +/* + * round_divide is part of math_utils, so you may need to import math_utils.h + * and link math_utils.o if you use the following macros. + */ +#define CELSIUS_TO_DECI_KELVIN(temp_c) \ + (round_divide(CELSIUS_TO_MILLI_KELVIN(temp_c), 100)) +#define DECI_KELVIN_TO_CELSIUS(temp_dk) \ + (MILLI_KELVIN_TO_CELSIUS((temp_dk) * 100)) +#define MILLI_KELVIN_TO_MILLI_CELSIUS(temp_mk) ((temp_mk) - 273150) +#define MILLI_CELSIUS_TO_MILLI_KELVIN(temp_mc) ((temp_mc) + 273150) +#define MILLI_KELVIN_TO_KELVIN(temp_mk) (round_divide((temp_mk), 1000)) +#define KELVIN_TO_MILLI_KELVIN(temp_k) ((temp_k) * 1000) +#define CELSIUS_TO_MILLI_KELVIN(temp_c) \ + (MILLI_CELSIUS_TO_MILLI_KELVIN((temp_c) * 1000)) +#define MILLI_KELVIN_TO_CELSIUS(temp_mk) \ + (round_divide(MILLI_KELVIN_TO_MILLI_CELSIUS(temp_mk), 1000)) /* Calculate a value with error margin considered. For example, * TARGET_WITH_MARGIN(X, 5) returns X' where X' * 100.5% is almost equal to |