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

[client-v2] Impossible to get float value by getFloat() because of incorrect overflow check #1954

Closed
chernser opened this issue Nov 19, 2024 · 0 comments · Fixed by #1955
Closed

Comments

@chernser
Copy link
Contributor

Describe the bug

If reader attempts to call getFloat() on a column of Float64 type and value fits float it still gets exception about overflow:

java.lang.ArithmeticException: float overflow: 1.1 cannot be presented as float

This happens because of this overflow check:

                 Number number = (Number) value;
                 if (number.floatValue() == number.doubleValue()) {
                    return number.floatValue();
                } else {
                    throw new ArithmeticException("float overflow: " + value + " cannot be presented as float");
                }

Obviously double value might have some "noise" fraction:

public void testCompareFloatAndDouble() {
        float f = 1.1f;
        double d = 1.1d;

        Assert.assertEquals(f, d);
    }

Output:

java.lang.AssertionError:
Expected :1.1
Actual   :1.100000023841858

The overflow check might be too complex from performance stand point, so this PR removes check for float and double.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant