Talk:Pow - Math
Jump to navigation
Jump to search
Alternative[edit source]
Math functions tend to be on the slow side, so I created a bit faster one.
Float Function power(Float base, Float exponent)
Float fPower = 1
Float i
if (exponent == 0.0)
return fPower
elseif exponent == 1.0
return base
endif
if exponent > 0.0
While i < exponent
fPower *= base
i += 1.0
EndWhile
return fPower
else
; because you might want to use a negative exponent.
i = exponent
While i < 0.0
fPower /= base
i += 1.0
EndWhile
return fPower
endif
EndFunction