Fix intDiv of const divider

This commit is contained in:
hcz 2020-02-25 12:58:26 +08:00
parent 1803656b9f
commit ba35ba01cf
3 changed files with 73 additions and 7 deletions

View File

@ -33,7 +33,7 @@ struct DivideIntegralByConstantImpl
{
size_t size = a.size();
for (size_t i = 0; i < size; ++i)
c[i] = -c[i];
c[i] = -a[i];
return;
}

View File

@ -21,3 +21,63 @@
0
0
0
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1

View File

@ -17,3 +17,9 @@ SELECT intDivOrZero( CAST(-1000, 'Int64') , CAST(1000, 'Int64') );
SELECT intDiv(-1, number) FROM numbers(1, 10);
SELECT intDivOrZero(-1, number) FROM numbers(1, 10);
SELECT intDiv(toInt32(number), -1) FROM numbers(1, 10);
SELECT intDivOrZero(toInt32(number), -1) FROM numbers(1, 10);
SELECT intDiv(toInt64(number), -1) FROM numbers(1, 10);
SELECT intDivOrZero(toInt64(number), -1) FROM numbers(1, 10);
SELECT intDiv(number, -number) FROM numbers(1, 10);
SELECT intDivOrZero(number, -number) FROM numbers(1, 10);