Check for integer overflow on multiplication | Function to check whether there is overflow in a * b or not . It returns true if there is overflow . ; Check if either of them is zero ; Driver code
< ? php function isOverflow ( $ a , $ b ) { if ( $ a == 0 $ b == 0 ) return false ; $ result = $ a * $ b ; if ( $ a == ( int ) $ result / $ b ) return false ; else return true ; } $ a = 10000000000 ; $ b = -10000000000 ; if ( isOverflow ( $ a , $ b ) ) echo " Yes " ; else echo " No " ; ? >