Icet
Icet

Reputation: 688

SQL Server changing value of float

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?

Upvotes: 0

Views: 654

Answers (3)

afsaneh
afsaneh

Reputation: 1

You can use real instead of float and its true to save

Upvotes: 0

Rajashekar V
Rajashekar V

Reputation: 33

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

Upvotes: 1

Tom H
Tom H

Reputation: 47464

The FLOAT data type is not a precise data type. If you need exact precision then you should be using DECIMAL or NUMERIC.

Upvotes: 4

Related Questions