Re: How to get more precision in C ?
>I would like to have precision upto atleast 8 digits in my numerical
>computation program. I have tried using doubles but I keep getting
>results only till 6 places after decimal. eg.
You only *print* 6 digits after the decimal. You may be getting greater
precision in the actual computation.
Try: printf("%300.200f", s);
although this is primarily useful for debugging. A double won't
have nearly this many digits of precision.
>#include <stdio.h>
>#define M_PI 3.14159265358979323846 /* M_PI is not defined in math.h
>according to my compiler*/
>
>int main(void)
>{
> double s;
> s = M_PI;
> printf("%f", s);
>
>
>return 0;
>
>}
|