Problem with floating point arithmatics

  • Thread starter Thread starter Francesco2017
  • Start date Start date
F

Francesco2017

Guest
Hi all,

Could anyone shed a light on this?

According to my calculator, if i do (100/43) * 22 = 51.162....

However the code below outputs 44.00 (limited to 2 decimal places).

What am i doing wrong, please?

Regards

Francesco C


double fraction = (100/43);
double percentage =fraction*22;
Console.WriteLine ("{0:F2}",percentage);

//Console outputs 44.00

Continue reading...
 
Back
Top