question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Loss of precision on Float fields

See original GitHub issue

Bug description

I have a price Float @default(0) field and while the value stored in the database row (postgres) is 0.69 the value returned by the prisma client is 0.6900000000000001 (this is a console.log on the output of .findMany)

Environment & setup

  • OS: ArchLinux
  • Database: PostgreSQL
  • Prisma version: 2.1.3
  • Node.js version: 12.17

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
esistgutcommented, Jul 22, 2020

Thank you, I deployed it to our staging environment. Everything seems to be ok. Should I find anything wrong I’ll keep you posted.

2reactions
pimeyscommented, Jul 21, 2020

Fix is done. Merging when reviewed and tests are green. You can read what was the issue from the PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Losing My Precision: Tips For Handling Tricky Floating Point ...
Loss of precision in converting into floating point; Adding numbers of very different magnitudes; Subtracting numbers of similar magnitudes; Multiplying and ...
Read more >
java - Loss of precision - int -> float or double - Stack Overflow
Casting to float will lose precision if the integral value has more than 24 significant bits. Casting to double will lose precision if...
Read more >
Why Do My Floating Point Numbers Lose Precision ... - Support
For this reason, you may experience a loss of precision, and some floating-point operations may produce unexpected results.
Read more >
Floating Point Numbers & Causes of Imprecision
INGRES lost precision on 1.00000005 because 9 decimal digits were entered, causing the least significant portion of the number to be lost.
Read more >
Demystifying Floating Point Precision
Floating point numbers have limited precision. If you are a game programmer, you have likely encountered bugs where things start breaking ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found