mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-23 10:10:50 +00:00
Fix correctness
This commit is contained in:
parent
a563ad0b21
commit
dabaef2836
@ -119,11 +119,11 @@ struct IntegerRoundingComputation
|
||||
}
|
||||
case RoundingMode::Round:
|
||||
{
|
||||
if (x < 0)
|
||||
x -= scale;
|
||||
switch (tie_breaking_mode)
|
||||
{
|
||||
case TieBreakingMode::Auto:
|
||||
if (x < 0)
|
||||
x -= scale;
|
||||
x = (x + scale / 2) / scale * scale;
|
||||
break;
|
||||
case TieBreakingMode::Bankers:
|
||||
@ -131,14 +131,10 @@ struct IntegerRoundingComputation
|
||||
T quotient = (x + scale / 2) / scale;
|
||||
if (quotient * scale == x + scale / 2)
|
||||
// round half to even
|
||||
x = (quotient & ~1) * scale;
|
||||
x = ((quotient + (x < 0)) & ~1) * scale;
|
||||
else
|
||||
{
|
||||
// round the others as usual
|
||||
if (x < 0)
|
||||
quotient -= 1;
|
||||
x = quotient * scale;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user