The code bellow is going to print a value with 12 digits precision
Code:
#include <stdio.h>
int main(void)
{
double c, xc=50800.287F, w, f=125000.0F;
w=2*3.14*f;
c=1/w*xc;
printf("capacitance value is : %.12f\n", c);
return 0;
}
Are you sure that double is not supported?I mean it is a primitive type of C.... What error do you get?
EDIT : Ok, i think you have a logical error.
What you want is
but you have
The problem is that in your code the code will be executed like this : (1/w)*xc
Mind also that you need at least 11 digits precision otherwise you will see only zeros.
And with a second thought i found out that float is ok.So i tried it...
Code:
#include <stdio.h>
int main(void)
{
float c, xc=50800.287, w, f=125000.0;
w=2*3.14*f;
c=1/(w*xc);
printf("capacitance value is : %.12f\n", c);
return 0;
}
and the output was
Code:
Macintosh-c8bcc88e5669-9:~ usi$ ./px
capacitance value is : 0.000000000025
Macintosh-c8bcc88e5669-9:~ usi$
Hope this helps