Check for integer overflow on multiplication | C # program to 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 function
using System ; public class GfG { static bool isOverflow ( long a , long b ) { if ( a == 0 b == 0 ) return false ; long result = a * b ; if ( a == result / b ) return false ; else return true ; } public static void Main ( ) { long a = 10000000000 ; long b = - 10000000000 ; if ( isOverflow ( a , b ) ) Console . WriteLine ( " Yes " ) ; else Console . WriteLine ( " No " ) ; } }