N root Function?

BlitzMax Forums/BlitzMax Programming/N root Function?

Arowx(Posted 2008) [#1]
Is there support for N Root maths in Blitzmax?

e.g. Root(power, value)

Regards

Al


Czar Flavius(Posted 2008) [#2]
By the power of maths
SuperStrict

Print "Square root of 4 is " + nroot(4, 2)
Print "Cube root of 27 is " + nroot(27, 3)

Function nroot:Float(number:Float, n:Float)
	Return number ^ (1/n)
End Function


To find the n-th root of a number, raise that number to the power of 1/n. So 4 to the power of (1/2) is 2.


Arowx(Posted 2008) [#3]
Excellent,

I now have the power! ;o)

Cheers