[SELECT ALL] Code:
//made by Kirin (iterative pow algorithm, exponents are forced into integers)
alias pow [
alias pow_exp $arg2
alias pow_base $arg1
if (= $pow_exp 0) [result 1] [
if (< $pow_exp 0) [*= pow_exp -1] []
-= pow_exp 1
loop i $pow_exp [*=f pow_base $arg1]
if (> $arg2 0) [result $pow_base] [result (divf 1 $pow_base)]
]
]
//[Kirin] format float/int to a precision eg. echo (formatprec 123,456 2) :outputs: 123,45
alias formatprec [
fp_number = $arg1
fp_mag = (pow 10 $arg2)
*=f fp_number $fp_mag
-= fp_number 0
fp_number = (divf $fp_number $fp_mag)
result $fp_number
]
this is a much more compact solution, plus it gives a free pow function :D
(if u are using V-Man's tools u can remove the pow alias, cause V-Man has already integrated it)