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

[BUG] libcudf.round doesn't fully work on certain values #17664

Open
galipremsagar opened this issue Dec 30, 2024 · 3 comments
Open

[BUG] libcudf.round doesn't fully work on certain values #17664

galipremsagar opened this issue Dec 30, 2024 · 3 comments
Labels
bug Something isn't working libcudf Affects libcudf (C++/CUDA) code.

Comments

@galipremsagar
Copy link
Contributor

Describe the bug
round method seems to be returning the actual value for the following inputs.

Steps/Code to reproduce bug

In [8]: import cudf

In [9]: s = cudf.Series([1.1320000000000001, 1.234234])

In [10]: s._column.round(decimals=3).element_indexing(0)
Out[10]: np.float64(1.1320000000000001)

In [11]: s._column.round(decimals=3).element_indexing(1)
Out[11]: np.float64(1.234)

Expected behavior

In [10]: s._column.round(decimals=3).element_indexing(0)
Out[10]: np.float64(1.132)

Environment overview (please complete the following information)

  • Environment location: [Bare-metal]
  • Method of cuDF install: [from source]
@galipremsagar galipremsagar added bug Something isn't working libcudf Affects libcudf (C++/CUDA) code. labels Dec 30, 2024
@vyasr
Copy link
Contributor

vyasr commented Dec 30, 2024

I'm going to guess that this is a floating point precision issue and the best representation of 1.132 is in fact 1.1320000000000001, so the latter is actually the rounded value. Worth looking into though.

@bdice
Copy link
Contributor

bdice commented Dec 30, 2024

This seems like an expected behavior due to how floating point representation works in binary. There is no exact binary representation for the decimal 1.132, it seems. Try it in https://www.h-schmidt.net/FloatConverter/IEEE754.html.

There are also some known differences between cudf and pandas in how we print floats.

@bdice
Copy link
Contributor

bdice commented Dec 30, 2024

Using a decimal column with appropriate scale is the correct way to get exact decimal representations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working libcudf Affects libcudf (C++/CUDA) code.
Projects
None yet
Development

No branches or pull requests

3 participants