Skip to content
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

fix floating to int128 and negative to int128 #2374

Merged
merged 1 commit into from
Nov 9, 2023

Conversation

Ashleyhx
Copy link
Contributor

@Ashleyhx Ashleyhx commented Nov 8, 2023

fix #2334

@Ashleyhx Ashleyhx marked this pull request as ready for review November 8, 2023 19:38
Copy link

codecov bot commented Nov 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (fd388b4) 91.01% compared to head (fba4023) 91.02%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2374   +/-   ##
=======================================
  Coverage   91.01%   91.02%           
=======================================
  Files        1015     1015           
  Lines       35823    35825    +2     
=======================================
+ Hits        32606    32611    +5     
+ Misses       3217     3214    -3     
Files Coverage Δ
src/common/types/int128_t.cpp 88.98% <100.00%> (+0.94%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@AEsir777 AEsir777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return cast(-170141183460469231731687303715884105728, "int128") reports error Cast failed. 170141183460469231731687303715884105728 is not within INT128 range. while -170141183460469231731687303715884105728 should be the smallest INT128 value.

@Ashleyhx
Copy link
Contributor Author

Ashleyhx commented Nov 8, 2023

Return cast(-170141183460469231731687303715884105728, "int128") reports error Cast failed. 170141183460469231731687303715884105728 is not within INT128 range. while -170141183460469231731687303715884105728 should be the smallest INT128 value.

I think we only allow -170141183460469231731687303715884105727 to 170141183460469231731687303715884105727 to avoid possible overflows.

@acquamarin
Copy link
Collaborator

acquamarin commented Nov 8, 2023

D select cast(-170141183460469231731687303715884105728 as  hugeint);
Error: Conversion Error: Type DOUBLE with value -1.7014118346046923e+38 can't be cast because the value is out of range for the destination type INT128

Looks like duckdb fails with this number. Not sure what is the limit.

@Ashleyhx
Copy link
Contributor Author

Ashleyhx commented Nov 8, 2023

D select cast(-170141183460469231731687303715884105728 as  hugeint);
Error: Conversion Error: Type DOUBLE with value -1.7014118346046923e+38 can't be cast because the value is out of range for the destination type INT128

Looks like duckdb fails with this number. Not sure what is the limit.

limit is -170141183460469231731687303715884105727 not -170141183460469231731687303715884105728. otherwise it will fail here for duckdb.

@AEsir777
Copy link
Collaborator

AEsir777 commented Nov 8, 2023

D select cast(-170141183460469231731687303715884105728 as  hugeint);
Error: Conversion Error: Type DOUBLE with value -1.7014118346046923e+38 can't be cast because the value is out of range for the destination type INT128

Looks like duckdb fails with this number. Not sure what is the limit.

limit is -170141183460469231731687303715884105727 not -170141183460469231731687303715884105728. otherwise it will fail here for duckdb.

Ah, okay. So maybe we need to modify the error message? 170141183460469231731687303715884105728 is not within INT128 range. or just leave it as it is.

@Ashleyhx Ashleyhx merged commit 6731798 into master Nov 9, 2023
12 checks passed
@Ashleyhx Ashleyhx deleted the round-float-to-int128 branch November 9, 2023 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect rounding from float to int128 and negative int128 to other types
3 participants