Jump to content

Recommended Posts

Posted (edited)

div.au3

;===============================================================================
      ;
      ; Function Name:  _Div()
      ; Description:      Devides $Num by $Devidant.
      ; Parameter(s): $Num - The Number you are deviding.
      ;                 $Devidant - The Number you are deviding by.
      ;                
      ;                 $Result[0] - The Whole Result
      ;                 $Result[1] - The remainder.
      ;
      ; Requirement(s):   None.
      ; Return Value(s):  The Whole Number and the remainder.
      ;                      @error is set to 1 if Devidant = 0.
      ; Author(s):      KJ
      ;
      ;===============================================================================
       
       Func _Div($Num,$Devidant)
       Local $Result[2]
       
       If $Num < 0 Then $Num = -$Num
       If $Devidant < 0 Then $Devidant = -$Devidant
       If $Devidant = 0 Then
        SetError(1)
        Return
       EndIf
        
        If $Num > $Devidant Then
            $Result[0] = Floor($Num/$Devidant)
            $Result[1] = $Num - ($Result[0]*$Devidant)
        
        ElseIf $Num = $Devidant Then
            $Result[0] = 1
            $Result[1] = 0
        
        ElseIf $Num < $Devidant Then
            $Result[0] = 0
            $Result[1] = $Num
        EndIf
       
       Return $Result
       EndFunc

Sample.au3

#include "div.au3"
 $a=_Div(50,9)
 If @error=0 Then MsgBox(0,"",$a[0] & "  " & $a[1])

what u all think ?

i personally think it should be addded to the autoit user functions.

Edited by DaProgrammer

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...