Check Integer Overflow
You have given two 32 bit signed integers, and you have to check if their multiplication will overflow 32 bit signed integer or not.
An integer overflow occurs when you attempt to store inside an integer variable a value that is larger than the maximum value the variable can hold.
Input format :
The first line of input contains the first 32 bit signed integer 'A'.
The second line of input contains the second 32 bit signed integer 'B'.
Output format :
The only line of output contains 'true' if the multiplication of 'A' and 'B' is overflowing in 32 bit signed integer or 'false' otherwise.
Note:
Return the expected boolean value from the function, no need to print anything.
Constraints :
-2^31 <= A <= 2^31 - 1
-2^31 <= B <= 2^31 - 1
where 'A' and 'B' are the given integers.
Time Limit: 0.5 sec.
Note :
Try to solve this problem assuming you can only have 32 bit signed integers (Without using any typecasting to other datatypes)
Be the first one to answer
Add answer anonymously...
Top Thoughts2Binary Consulting & Solutions Software Developer interview questions & answers
Popular interview questions of Software Developer
>
Thoughts2Binary Consulting & Solutions Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app