Skip to content

Switch floating point division and modulo to use IEEE semantics for division by zero by default, and add ieee_floating_point_ops setting that can be used to revert back to old behavior #13493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 23, 2024

Conversation

Mytherin
Copy link
Collaborator

Implements #10956

This PR changes the behavior of floating point division/modulo by zero to by default follow IEEE-754 semantics, i.e. the following results are returned:

expr result
1.0 / 0 inf
1.0 / -0 -inf
-1.0 / 0 -inf
-1.0 / -0 inf
0.0 / 0 nan
0.0 / -0 nan
nan / -0 nan
nan / 0 nan
inf / 0 inf
inf / -0 -inf

Previously all of these would return NULL.

The ieee_floating_point_ops setting is added which can be used to return to the previous behavior, by setting this to false.

SET ieee_floating_point_ops=false;

e.g.:

D select 1.0 / 0.0 AS result;
┌────────┐
│ result │
│ double │
├────────┤
│    inf │
└────────┘
D SET ieee_floating_point_ops=false;
D select 1.0 / 0.0 AS result;
┌────────┐
│ result │
│ double │
├────────┤
│   NULL │
└────────┘

…ivision by zero by default, and add ieee_floating_point_ops setting that can be used to revert back to old behavior
@duckdb-draftbot duckdb-draftbot marked this pull request as draft August 22, 2024 09:30
@Mytherin Mytherin marked this pull request as ready for review August 22, 2024 14:48
@Mytherin Mytherin merged commit 627a702 into duckdb:main Aug 23, 2024
39 checks passed
@Mytherin Mytherin deleted the fpdivbyzero branch August 28, 2024 14:02
github-actions bot pushed a commit to duckdb/duckdb-r that referenced this pull request Sep 7, 2024
Merge pull request duckdb/duckdb#13493 from Mytherin/fpdivbyzero
Merge pull request duckdb/duckdb#13515 from carlopi/bump_sqlite_mysql
github-actions bot added a commit to duckdb/duckdb-r that referenced this pull request Sep 7, 2024
Merge pull request duckdb/duckdb#13493 from Mytherin/fpdivbyzero
Merge pull request duckdb/duckdb#13515 from carlopi/bump_sqlite_mysql

Co-authored-by: krlmlr <krlmlr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Documentation Use for issues or PRs that require changes in the documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant