Fix error

This commit is contained in:
Alexey Milovidov 2020-08-08 05:02:36 +03:00
parent ec281cd703
commit 6663f21fdd
3 changed files with 11 additions and 10 deletions

View File

@ -49,9 +49,10 @@ struct LCMImpl
*/
using Int = typename NumberTraits::ToInteger<Result>::Type;
using Unsigned = std::make_unsigned_t<Int>;
Int val1 = abs<Int>(a) / std::gcd(Int(a), Int(b));
Int val2 = abs<Int>(b);
Unsigned val1 = abs<Int>(a) / std::gcd(Int(a), Int(b));
Unsigned val2 = abs<Int>(b);
/// Overflow in implementation specific way.
return Result(val1 * val2);

View File

@ -2,7 +2,7 @@
30
30
30
18446744073709551360
-256
-256
-256
0
0
0
0

View File

@ -4,7 +4,7 @@ SELECT lcm(15, -10);
SELECT lcm(-15, -10);
-- Implementation specific result on overflow:
SELECT lcm(256, 9223372036854775807);
SELECT lcm(256, -9223372036854775807);
SELECT lcm(-256, 9223372036854775807);
SELECT lcm(-256, -9223372036854775807);
SELECT ignore(lcm(256, 9223372036854775807));
SELECT ignore(lcm(256, -9223372036854775807));
SELECT ignore(lcm(-256, 9223372036854775807));
SELECT ignore(lcm(-256, -9223372036854775807));