Logo

Programming-Idioms

History of Idiom 86 > diff from v21 to v22

Edit summary for version 22 by DantHimself:
[Csharp] wrong

Version 21

2019-10-08, 14:34:04

Version 22

2019-10-08, 14:34:49

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
public bool WillOverwflow(int x, int y) => int.MaxValue / x > y;
Code
public bool WillOverwflow(int x, int y) => int.MaxValue / x < y;