significant figures, resolution

be able to read significant figures up to 1/10 of the resolution. 

resolution : the quanta of a measure

 

in computers,

information loss occurs.

 

if the num of significant figures = 9, then

 123456789.

-                  0.123456789

---------------------------------------

 123456789.

 

 

#include <stdio.h>

int main () {

        float a = 1234567.f;

        float b =              0.1234567f;


        printf("%.7f %.14f\n", a, b);

        printf("%.7f %.14e\n", a+b, a+b);


        return 0;

}


result:

1234567.0000000 0.12345670163631

1234567.1250000 1.23456712500000e+06

 

 

when float -> double, the result is

1234567.0000000 0.12345670000000

1234567.1234567 1.23456712345670e+06

 -------------------------------------------------------------------------

#include <stdio.h>

int main () {

        double a = 123456789.111111111;

        double b =                   0.111111111111111111;


        printf("%.20lf %.20lf\n", a, b);

        printf("%.20lf %.20e\n", a+b, a+b);


        return 0;

}

 

result:

123456789.11111110448837280273 0.11111111111111110494

123456789.22222220897674560547 1.23456789222222208977e+08





Write a comment

Comments: 0