I have an existing table in a database of my client and there has an attribute with data type REAL
. How do I represent in C #? float
or decimal
? What is the best way?
I have an existing table in a database of my client and there has an attribute with data type REAL
. How do I represent in C #? float
or decimal
? What is the best way?
Depends on content. It depends on whether you want values accuracy.
Almost always I go from decimal
which gives the correctness, it is useful for monetary or other typical values that the exact unit is important, this is valid for several types of measures. But the database would need to be of a compatible type.
But it can go from double
, possibly float
, depends on the database. If the database is as REAL
, it should be the most appropriate, the real-type is floating-point semantics like these C # types.
What you may wonder is if the database is wrong and already causing a problem for the system.