September 26, 2013 at 9:18 am
Hi!
I'm having a strange behaviour with a stored procedure that has some parameters in float format.
I used:
float x = (float)1.5;
float y= (float)4.3;
...
row["x"] = x;
row["y"] = y;
I passed both parameters as this:
cmd.Parameters.Add("@y", SqlDbType.Float).Value = (float)row["x"];
cmd.Parameters.Add("@x", SqlDbType.Float).Value = (float)row["y"];
And when I check in the data saved in database, it appears like this:
x = 1,5
y = 4,30000019073486
Anyone knows why this happens?
Regards
September 26, 2013 at 10:08 am
That's because float and real are not exact numeric data types, they're approximate numerics and can generate different values than the ones intended.
September 26, 2013 at 10:13 am
Thanks!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply