Logo

Programming-Idioms

History of Idiom 86 > diff from v9 to v10

Edit summary for version 10 by :
New Java implementation by user [dj]

Version 9

2016-02-18, 16:58:02

Version 10

2016-02-21, 01:35:54

Idiom #86 Check if integer multiplication will overflow

Write boolean function multiplyWillOverflow which takes two integers x, y and return true if (x*y) overflows.

Idiom #86 Check if integer multiplication will overflow

Write boolean function multiplyWillOverflow which takes two integers x, y and return true if (x*y) overflows.

Code
static boolean multiplyWillOverflow(int x, int y) {
	return Integer.MAX_VALUE/x < y;
}