mirror of
https://github.com/inkarkat/vim-ingo-library.git
synced 2026-05-29 11:18:51 +02:00
This commit is contained in:
@@ -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 :
|
||||
|
||||
Reference in New Issue
Block a user