If I have a decimal such as 9.999999999
what will I want in my ASP.NET MVC 4 Models to allow this type of decimal to be stored AS IS in the database? I believe float is the correct answer. But I am checking here before changing my models over.
Asked
Active
Viewed 83 times
0

TheWebs
- 12,470
- 30
- 107
- 211
1 Answers
0
The C# decimal
type has the highest precision but it uses more memory and performs slower than float
or double
types.
The float
type only has 7 digit precision, so will certainly not be suitable for 9.999999999
.
I would go with decimal
unless performance is critical for your application.
You can find excellent information at: What is the difference between Decimal, Float and Double in C#?
-
if float will let me go to 7 then that's fine, I find decimal only goes to 2 decimals. – TheWebs May 25 '13 at 23:44
-
`decimal` will go up to 29 significant figures! You should use it if precision is critical for your app. `float` & `double` are less precise and also susceptible to tiny rounding issues, see [the question](http://stackoverflow.com/questions/618535/what-is-the-difference-between-decimal-float-and-double-in-c) for more info. – davmos May 26 '13 at 00:00