Skip to content

fix(int128): Use all 16 decimal digits to represent int128 min/max in double number correctly #8633

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TreeHunter9
Copy link
Contributor

The value I128_MIN_dbl was not represented precisely, as it didn't utilize all 16 decimal digits (52 bits of mantissa) available in a double-precision number. As a result, the value was rounded down to the closest representable number in the double format.

This inaccuracy led to an error in the following query:

SELECT CAST(-POWER(2, 127) AS INT128) FROM RDB$DATABASE;
=======================
Statement failed, SQLSTATE = 22003
arithmetic exception, numeric overflow, or string truncation
-numeric value is out of range

@dyemanov dyemanov requested a review from AlexPeshkoff June 27, 2025 13:48
static const CDecimal128 I128_MIN_dcft("-1.701411834604692317316873037158841E+38", decSt);
static const CDecimal128 I128_MAX_dcft("1.701411834604692317316873037158841E+38", decSt);
static const CDecimal128 I128_MAX_dcft( "1.701411834604692317316873037158841E+38", decSt);
Copy link
Member

Choose a reason for hiding this comment

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

Why whitespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To look in line with I128_MIN_dcft, like it's done with I128_MIN_dbl and I128_MAX_dbl

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.

2 participants