0
float number1 =12.1F;
double number2 = (double) number1;
MessageBox.Show(number2.ToString());

gives the result 12.1000003814697.Float is 32 bit size type and double is a 64 bit type. Sow I am going from a smaller to bigger size type. Why does it change the value of the variable?

  • check https://stackoverflow.com/questions/916081/convert-float-to-double-without-losing-precision Although this is a java question, the answer is valid for c# as well. – Fortega Dec 12 '17 at 13:47
  • and this explains a bit as well: [ifference-between-decimal-float-and-double-in-net](https://stackoverflow.com/questions/618535/difference-between-decimal-float-and-double-in-net) – Patrick Artner Dec 12 '17 at 13:52

0 Answers0