Jump to content

Recommended Posts

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!

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
×
×
  • Create New...