In C#, what data type should I use to represent monetary amounts? Decimal? Float? Double? I want to take in consideration: precision, rounding, etc.
C# Money Data Type – Best Data Type to Represent Money in C#
c++
c++
In C#, what data type should I use to represent monetary amounts? Decimal? Float? Double? I want to take in consideration: precision, rounding, etc.
Best Answer
Use
System.Decimal
:Neither
System.Single
(float
) norSystem.Double
(double
) areprecise enoughcapable of representing high-precision floating point numbers without rounding errors.