为了表示浮点数,我们使用float,double和long double,有什么不同 ?
double的精度是float的2倍。
float是32位IEEE 754单精度浮点数1位符号,(8位为指数,23 *为值),即float具有7位十进制数字精度。
double是64位的IEEE 754双精度浮点数(符号1位,指数11位,值52 *位),即double具有15位十进制数字的精度。
让我们举个例子:
对于二次方程x2 – 4.0000000 x + 3.9999999 = 0,精确到10个有效数字的根是r1 = 2.000316228和r2 = 1.999683772
// C program to demonstrate
// double and float precision values
#include <stdio.h>
#include <math.h>
// utility function which calculate roots of
// quadr