Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-04-24 04:37:48 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-04-24 04:37:48 +0300
commitbdf6393c98cf87d1e67e6b664037a00383806ffe (patch)
treed448186859c7cd3bd2df16751202ba687b314fd8 /source/blender/blenlib/intern/math_base.c
parentf829f556b430050ff8e87e7f287a468e94cd7e77 (diff)
Math Lib: pow_i for int power-of
Diffstat (limited to 'source/blender/blenlib/intern/math_base.c')
-rw-r--r--source/blender/blenlib/intern/math_base.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/blenlib/intern/math_base.c b/source/blender/blenlib/intern/math_base.c
index cddfde371f5..0a1e9e8a8a1 100644
--- a/source/blender/blenlib/intern/math_base.c
+++ b/source/blender/blenlib/intern/math_base.c
@@ -31,6 +31,21 @@
#include "BLI_strict_flags.h"
+int pow_i(int base, int exp)
+{
+ int result = 1;
+ BLI_assert(exp >= 0);
+ while (exp) {
+ if (exp & 1) {
+ result *= base;
+ }
+ exp >>= 1;
+ base *= base;
+ }
+
+ return result;
+}
+
/* from python 3.1 floatobject.c
* ndigits must be between 0 and 21 */
double double_round(double x, int ndigits)