Dividing a double with integer

Posted by hardcoder on Stack Overflow See other posts from Stack Overflow or by hardcoder
Published on 2010-06-16T06:33:01Z Indexed on 2010/06/16 6:42 UTC
Read the original article Hit count: 189

I am facing an issue while dividing a double with an int. Code snippet is :

  double db = 10;
  int fac = 100;
  double res = db / fac;

The value of res is 0.10000000000000001 instead of 0.10.

Does anyone know what is the reason for this? I am using cc to compile the code.

© Stack Overflow or respective owner

Related posts about c

    Related posts about floating-point