From 7b9a0ed8c47dfef03e8b21cafae3b5438bc93415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 25 May 2018 12:34:02 +0200 Subject: BLI: Utils: Add Macro that compute the number of digits in integers type. Usefull if you want to create char chains to contains hashes of a certain type. --- source/blender/blenlib/BLI_utildefines.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 75ddb5e739c..9c90b86832a 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -629,6 +629,14 @@ extern bool BLI_memory_is_zero(const void *arr, const size_t arr_size); # define UNLIKELY(x) (x) #endif +/* Expands to an integer constant expression evaluating to a close upper bound + * on the number the number of decimal digits in a value expressible in the + * integer type given by the argument (if it is a type name) or the the integer + * type of the argument (if it is an expression). The meaning of the resulting + * expression is unspecified for other arguments. + * i.e: DECIMAL_DIGITS_BOUND(uchar) is equal to 3. */ +#define DECIMAL_DIGITS_BOUND(t) (241 * sizeof(t) / 100 + 1) + #ifdef __cplusplus } #endif -- cgit v1.2.3