[Bf-blender-cvs] [7b9a0ed8c47] blender2.8: BLI: Utils: Add Macro that compute the number of digits in integers type.

Clément Foucault noreply at git.blender.org
Wed May 30 12:25:22 CEST 2018


Commit: 7b9a0ed8c47dfef03e8b21cafae3b5438bc93415
Author: Clément Foucault
Date:   Fri May 25 12:34:02 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB7b9a0ed8c47dfef03e8b21cafae3b5438bc93415

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.

===================================================================

M	source/blender/blenlib/BLI_utildefines.h

===================================================================

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



More information about the Bf-blender-cvs mailing list