EmbLogic's Blog

unexpected output???

#include<stdio.h>
int main(void)
{
float a,b;
b=2.0e20+1.0;
a=b-2.0e20;
printf(“%f\n”,a);
return 0;
}
output is  :    4008175468544.000000
how this can be possible????????????????

3 Responses to unexpected output???

  1. mohit sharma says:

    m also havin d same output 4 dis code…
    n also the output is correct as the value 4 unsigned int can reach upto a number that can be expressed in the form of e…

    • sumit says:

      float is of 4 bytes..so the value assigned by us to b is the case of overflow..hence the ans is of compiler’s choice..

      actually its range is till 2million i.e 10 digits..

      n also for accesing exponential we use %e instead of %f…

Leave a Reply to sumit Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>