0

I have got a SQL table with a property 'Stock' and datatype float. According to several posts the equivalent type in C# is double.

So I have got a input which is a string and I convert it to a double value like this:

var number = Convert.ToDouble(numberAsString, CultureInfo.CurrentCulture.NumberFormat);

I have the follwing code to add the number on top of the stock:

result.Bestand += number;

Somehow (this is really strange to me) if I add "0,1" exactly three times, the value changes to 15,299999999999999. I don't know why though.

Remember: I am using commas instead of decimal points.

Tom el Safadi
  • 6,164
  • 5
  • 49
  • 102

1 Answers1

0

You should use numeric/decimal type in SQL. But why there is a need to read a value as string if you have the stock is of type float?