diff options
author | Lennart Weller <lhw@ring0.de> | 2017-09-17 22:17:33 +0000 |
---|---|---|
committer | Lennart Weller <lhw@ring0.de> | 2017-09-17 22:17:33 +0000 |
commit | 6aaf5ba7ed0980c14bdc554fc8839a2126455ed5 (patch) | |
tree | 6161925716661486e7f47c479668a9487b039d83 /src/storage_number.h | |
parent | New upstream version 1.7.0+dfsg (diff) | |
download | netdata-6aaf5ba7ed0980c14bdc554fc8839a2126455ed5.tar.xz netdata-6aaf5ba7ed0980c14bdc554fc8839a2126455ed5.zip |
New upstream version 1.8.0+dfsgupstream/1.8.0+dfsg
Diffstat (limited to 'src/storage_number.h')
-rw-r--r-- | src/storage_number.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/storage_number.h b/src/storage_number.h index 34ed0d89c..3c1b6bab3 100644 --- a/src/storage_number.h +++ b/src/storage_number.h @@ -14,6 +14,10 @@ typedef long double collected_number; #define COLLECTED_NUMBER_FORMAT "%0.7Lf" */ +#define calculated_number_llrint(x) llrintl(x) +#define calculated_number_round(x) roundl(x) +#define calculated_number_fabs(x) fabsl(x) + typedef uint32_t storage_number; #define STORAGE_NUMBER_FORMAT "%u" @@ -28,7 +32,7 @@ typedef uint32_t storage_number; #define SN_FLAGS_MASK (~(0x6 << 24)) // extract the flags -#define get_storage_number_flags(value) ((((storage_number)value) & (1 << 24)) | (((storage_number)value) & (2 << 24)) | (((storage_number)value) & (4 << 24))) +#define get_storage_number_flags(value) ((((storage_number)(value)) & (1 << 24)) | (((storage_number)(value)) & (2 << 24)) | (((storage_number)(value)) & (4 << 24))) #define SN_EMPTY_SLOT 0x00000000 // checks @@ -40,13 +44,13 @@ calculated_number unpack_storage_number(storage_number value); int print_calculated_number(char *str, calculated_number value); -#define STORAGE_NUMBER_POSITIVE_MAX 167772150000000.0 -#define STORAGE_NUMBER_POSITIVE_MIN 0.00001 -#define STORAGE_NUMBER_NEGATIVE_MAX -0.00001 -#define STORAGE_NUMBER_NEGATIVE_MIN -167772150000000.0 +#define STORAGE_NUMBER_POSITIVE_MAX (167772150000000.0) +#define STORAGE_NUMBER_POSITIVE_MIN (0.0000001) +#define STORAGE_NUMBER_NEGATIVE_MAX (-0.0000001) +#define STORAGE_NUMBER_NEGATIVE_MIN (-167772150000000.0) // accepted accuracy loss #define ACCURACY_LOSS 0.0001 -#define accuracy_loss(t1, t2) ((t1 == t2 || t1 == 0.0 || t2 == 0.0) ? 0.0 : (100.0 - ((t1 > t2) ? (t2 * 100.0 / t1 ) : (t1 * 100.0 / t2)))) +#define accuracy_loss(t1, t2) (((t1) == (t2) || (t1) == 0.0 || (t2) == 0.0) ? 0.0 : (100.0 - (((t1) > (t2)) ? ((t2) * 100.0 / (t1) ) : ((t1) * 100.0 / (t2))))) #endif /* NETDATA_STORAGE_NUMBER_H */ |