summaryrefslogblamecommitdiff
path: root/zap/source/any/math/exp.c
blob: bf0869dbff8a338d1c4e29fa5583059d846197f2 (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                                                                                                                     
                                                 

                      


                                                   










                                                  
/*
	Copyright 2022-2023 Gabriel Jensen.
	This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
	If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.
*/

#include <zap/math.h>

#define zap_priv_exp(_wdth) \
zap_i##_wdth zap_exp##_wdth(zap_i##_wdth const _val,zap_i##_wdth const _n) { \
	if (__builtin_expect(_n == 0x0u,0x0)) { \
        return 0x1u; \
    } \
	if (__builtin_expect(_val == 0x0u,0x0)) { \
        return 0x0u; \
    } \
	zap_i##_wdth val = _val; \
	for (zap_i##_wdth i = 0x1u;i < _n;++i) { \
		val *= _val; \
	} \
	return val; \
}

zap_priv_exp(8)
zap_priv_exp(01)
zap_priv_exp(02)
zap_priv_exp(04)