Sign in to follow this  
Followers 0
James

Pow()

8 posts in this topic

#1 ·  Posted (edited)

Hi all,

Does anyone have a mathematics, Pow() function?

Thanks,

James

Edit:

This is right isn't it?

Func Pow($x, $y)
    Return $x ^ $y
EndFunc
Edited by JamesBrooks

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Woo. I never needed this until now muttley

Shouldn't these basic math functions be added to the Math UDF? I mean, it's maths and so is the function. I am sure there are loads more like LambertW which should be added etc.

Edited by JamesBrooks

Share this post


Link to post
Share on other sites

Pow doesn't need to be added because the operator has been there for a LONG time.

Share this post


Link to post
Share on other sites

So you didn't read the help file from front to back like everyone else?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

For those of you who doesn't trust fancy mathematical operators like '*', '/' or '^' I've made 3 unsigned integer functions that only uses the '+' and '-' signs.

MsgBox(0,"2*3",_Multiply(2,3))
MsgBox(0,"9/3",_Division(9,3))
MsgBox(0,"5^2",_Pow(5,2))



Func _Pow($f1,$f2)
    Local $answer=1
    For $i=0 To $f2-1
        $answer=_Multiply($answer,$f1)
    Next
    Return $answer
EndFunc


Func _Multiply($f1,$f2)
    Local $answer=0
    For $i=0 To $f2-1
        $answer+=$f1
    Next
    Return $answer
EndFunc


Func _Division($f1,$f2)
    If $f2=0 Then Return "1.#INF"
    Local $answer=0
    While $f1>0
        $answer+=1
        $f1-=$f2
    WEnd
    If $f1<0 Then
        $answer-=1
    EndIf
    Return $answer
EndFunc
Edited by monoceres

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0