Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Arithmetic overflow error for type money

Tags:

c#

sql

I am getting sql exception (Arithmetic overflow error) for type money.How to set min and max value for money in c#. my sql type is money and C# datatype is double. Range of money is (-922,337,203,685,477.5808) to (922,337,203,685,477.5807).

like image 239
prawin Avatar asked Mar 31 '26 17:03

prawin


1 Answers

You should use decimal for money operations. Decimal - specific type which is what you need when it comes to money manipulations. So if it is important for you to have precisely correct results - use it. Otherwise - double is fine.


double (System.Double) ±5.0 x 10-324 to ±1.7 x 10308 with 15 or 16 significant figures
decimal (System.Decimal) ±1.0 x 10-28 to ±7.9 x 1028 with 28 or 29 significant figures

like image 190
Anatolii Gabuza Avatar answered Apr 03 '26 06:04

Anatolii Gabuza



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!