0
int main()
{
float b=123.1265;
printf("%f\t",b);
return 0;
}

OUTPUT is 123.126503

now my question is from where this 03 is coming in the output.. I tried with random numbers but every time I got random output rather than the value I assigned..

Adi
  • 1
  • 1
  • A base-10 number does not convert perfectly to a base-2 number. On converting back (print) a small error might be noticed. – Paul Ogilvie Jul 01 '17 at 17:50
  • Precision of `float` is not very high. You can use `double` to maintain precision. – MKR Jul 01 '17 at 18:07
  • OP, if you are having trouble understanding the issues of float precision, I would recommend reading about [IEEE 754 Floating-Point Arithmetic](https://en.wikipedia.org/wiki/IEEE_754) as well as [this example of how IEEE 754 Floating-Point numbers are translated into binary](http://www.madirish.net/240). – Spencer D Jul 01 '17 at 18:23
  • Computers cant store exact value of number and use a rounding method on corresponding binary numbers to obtain a decimal number. – EsmaeelE Jul 01 '17 at 22:09

0 Answers0