Division without using ' / ' operator | Function to find division without using ' / ' operator ; Handling negative numbers ; if num1 is greater than equal to num2 subtract num2 from num1 and increase quotient by one . ; checking if neg equals to 1 then making quotient negative ; Driver program
< ? php function division ( $ num1 , $ num2 ) { if ( $ num1 == 0 ) return 0 ; if ( $ num2 == 0 ) return INT_MAX ; $ negResult = false ; if ( $ num1 < 0 ) { $ num1 = - $ num1 ; if ( $ num2 < 0 ) $ num2 = - $ num2 ; else $ negResult = true ; } else if ( $ num2 < 0 ) { $ num2 = - $ num2 ; $ negResult = true ; } $ quotient = 0 ; while ( $ num1 >= $ num2 ) { $ num1 = $ num1 - $ num2 ; $ quotient ++ ; } if ( $ negResult ) $ quotient = - $ quotient ; return $ quotient ; } $ num1 = 13 ; $ num2 = 2 ; echo division ( $ num1 , $ num2 ) ; ? >