Files
SDK_SG200x_V2/linux_5.10/lib/math/int_pow.c
carbon 0545e9dc6d init version 2024-05-07
commit d1edce71135cc6d98c0a4b5729774542b676e769
Author: sophgo-forum-service <forum_service@sophgo.com>
Date:   Fri Mar 15 16:07:33 2024 +0800

    [fix] recommend using ssh method to clone repo.
    [fix] fix sensor driver repo branch name.
2024-05-07 19:36:36 +08:00

33 lines
631 B
C

// SPDX-License-Identifier: GPL-2.0
/*
* An integer based power function
*
* Derived from drivers/video/backlight/pwm_bl.c
*/
#include <linux/export.h>
#include <linux/kernel.h>
#include <linux/types.h>
/**
* int_pow - computes the exponentiation of the given base and exponent
* @base: base which will be raised to the given power
* @exp: power to be raised to
*
* Computes: pow(base, exp), i.e. @base raised to the @exp power
*/
u64 int_pow(u64 base, unsigned int exp)
{
u64 result = 1;
while (exp) {
if (exp & 1)
result *= base;
exp >>= 1;
base *= base;
}
return result;
}
EXPORT_SYMBOL_GPL(int_pow);