I created console application where I'm using EF. I've got model where are some float variables. In my Database I also use FLOAT.
In c# I have got this value: 3,3 After insert it to my database there is value: 3,29999995231628
Why is it happening?
I created console application where I'm using EF. I've got model where are some float variables. In my Database I also use FLOAT.
In c# I have got this value: 3,3 After insert it to my database there is value: 3,29999995231628
Why is it happening?
The FLOAT
data type is not a precise data type. If you need exact precision then you should be using DECIMAL
or NUMERIC
.
This is because FLOAT
is an approximate numeric datatype. You can use DECIMAL
or NUMERIC
, instead.
For detailed explanation, check this SO post: Difference between numeric, float and decimal in SQL Server