Merge tag 'trace-v5.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt...
[linux/fpc-iii.git] / lib / math / int_pow.c
blob0cf426e69bdaae6d26058fb19e5ddf1c3ad3421c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * An integer based power function
5 * Derived from drivers/video/backlight/pwm_bl.c
6 */
8 #include <linux/export.h>
9 #include <linux/math.h>
10 #include <linux/types.h>
12 /**
13 * int_pow - computes the exponentiation of the given base and exponent
14 * @base: base which will be raised to the given power
15 * @exp: power to be raised to
17 * Computes: pow(base, exp), i.e. @base raised to the @exp power
19 u64 int_pow(u64 base, unsigned int exp)
21 u64 result = 1;
23 while (exp) {
24 if (exp & 1)
25 result *= base;
26 exp >>= 1;
27 base *= base;
30 return result;
32 EXPORT_SYMBOL_GPL(int_pow);