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.

Zero-trailing issue with domains (Numeric value does not fit in a System.Decimal)

See original GitHub issue

I have a domain: CREATE DOMAIN amount_type AS numeric(34,18) It’s used in model like: [Column(TypeName = "amount_type")] decimal ; I have two problems:

  1. inserting “0.1” gives back “0.100000000000000000” when reading
  2. selecting, lets say, x=>new {mul = x.a * x.b} - gives “Numeric value does not fit in a System.Decimal” even if numbers are 0.1 (as an examples) because of number of trailing zeros

Recently it wasn’t the case (everything worked well) Can it be considered as a bug? Is there any workaround?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
YohDeadfallcommented, Nov 16, 2018

@alexk8 Sorry, I completely forgot about the issue. @roji Thanks for reminding me.

There is no bug, and the numeric handler behaves as expected. The problem hides in the type specified for columns. It’s numeric(34,18). What does this mean? This means that PostgreSQL will convert any value to the numeric with 18 digits after the dot. Therefore, you have 0.200000000000000000 in the database instead of 0.2.

I’m going to close the issue, but don’t hesitate to ask further questions.

1reaction
rojicommented, Nov 14, 2018

@YohDeadfall a reminder to try to look into this when you have some time…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Numeric value does not fit in a System.Decimal
Now when I select that column, using below query, it returns the value that will properly fits in decimal data type of c#,...
Read more >
Numeric value does not fit in a System.Decimal (value less ...
I first looked at posts with a similar issues, for example ... OverflowException: 'Numeric value does not fit in a System.Decimal' Stack ...
Read more >
Handling large decimal number - Microsoft Power BI Community
Error: An error happened while reading data from the provider: 'Numeric value does not fit in a System.Decimal' " is there a way...
Read more >
[Solved]-Numeric value does not fit in a System.Decimal-Entity ...
Navigate to the <EntitySet> tag, and add the select query. Now when I select that column, using below query, it returns the value...
Read more >
In some system decimal places are not considering
If the API is sending the data as a string instead of a numeric value, for example, this could cause issues with decimal...
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