This commit is contained in:
Ingo Karkat
2016-12-28 00:00:00 +01:00
parent f725e04e51
commit e656b9f9ba
+27
View File
@@ -32,4 +32,31 @@ function! ingo#math#BitsRequired( num )
return l:bitCnt
endfunction
"******************************************************************************
"* PURPOSE:
" Return the power of a:x to the exponent a:y as a Number.
"* ASSUMPTIONS / PRECONDITIONS:
" None.
"* EFFECTS / POSTCONDITIONS:
" None.
"* INPUTS:
" a:x Number.
" a:y Exponent.
"* RETURN VALUES:
" Number.
"******************************************************************************
if exists('*pow')
function! ingo#math#PowNr( x, y )
return float2nr(pow(a:x, a:y))
endfunction
else
function! ingo#math#PowNr( x, y )
let l:r = a:x
for l:i in range(a:y - 1)
let l:r = l:r * a:x
endfor
return l:r
endfunction
endif
" vim: set ts=8 sts=4 sw=4 noexpandtab ff=unix fdm=syntax :