Skip to content

gcd returns negative results #11098

@jonahgao

Description

@jonahgao

Describe the bug

According to the Binary GCD algorithm, its result cannot be a negative number.

截屏2024-06-24 21 31 30

To Reproduce

DataFusion CLI v39.0.0
> select gcd(-100, 0), gcd(0, -100);
+---------------------------+---------------------------+
| gcd(Int64(-100),Int64(0)) | gcd(Int64(0),Int64(-100)) |
+---------------------------+---------------------------+
| -100                      | -100                      |
+---------------------------+---------------------------+

Expected behavior

In PostgreSQL

postgres=# select gcd(-100, 0), gcd(0, -100);
 gcd | gcd
-----+-----
 100 | 100
(1 row)

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions