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

Decimal Type having precision loss when retrieving value from database #1675

Open
adityashFT opened this issue Jan 3, 2025 · 1 comment
Open

Comments

@adityashFT
Copy link

Software versions

  • Tedious: 18.6.1
  • SQL Server: 12.0.2000.8
  • Node.js: 22.11.0

Additional Libraries Used and Versions
Sequelize: 6.37.5

Problem description
In our Database Table, we have a column of type Decimal(38,20). When saving the value 500, the record in the table is correct, however the data that is returned by is 499.99999999999994

When investigating, I have come across this Issue (#678), which was raised 7 years ago. However, there seems to be no progress in addressing the issue, our team relays in the column being of type decimal, but the value returned by tedious is incorrect, which are causing issues in the program.

Requesting a quick fix on this issue or a temporary workaround to fix the decimal precision issue. One way is to change the column type to varchar, which is not a solution we prefer.

Expected behavior
Value returned should be exactly 500

Actual behavior
Value returned should be exactly 499.99999999999994

Any other details that can be helpful
According to my analysis

return new Result((value * sign) / Math.pow(10, scale), offset);
This line seems to be causing the precision issue, but haven't deep-dived to check what is actual issue is.

@adityashFT
Copy link
Author

Is there any update??

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

No branches or pull requests

1 participant