Zero-trailing issue with domains (Numeric value does not fit in a System.Decimal)
See original GitHub issueI 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:
- inserting “0.1” gives back “0.100000000000000000” when reading
- 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:
- Created 5 years ago
- Comments:12 (7 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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 have0.200000000000000000
in the database instead of0.2
.I’m going to close the issue, but don’t hesitate to ask further questions.
@YohDeadfall a reminder to try to look into this when you have some time…