65,210
社区成员
发帖
与我相关
我的任务
分享
...
#define DBL_DIG 15 /* # of decimal digits of precision */
#define DBL_EPSILON 2.2204460492503131e-016 /* smallest such that 1.0+DBL_EPSILON != 1.0 */
#define DBL_MANT_DIG 53 /* # of bits in mantissa */
#define DBL_MAX 1.7976931348623158e+308 /* max value */
#define DBL_MAX_10_EXP 308 /* max decimal exponent */
#define DBL_MAX_EXP 1024 /* max binary exponent */
#define DBL_MIN 2.2250738585072014e-308 /* min positive value */
#define DBL_MIN_10_EXP (-307) /* min decimal exponent */
#define DBL_MIN_EXP (-1021) /* min binary exponent */
#define _DBL_RADIX 2 /* exponent radix */
#define _DBL_ROUNDS 1 /* addition rounding: near */
...
//因为浮点数在计算机中都误差,如果对精度要求很高,就不要用了。
#include <stdio.h>
typedef struct tagFloat
{
int exponent; //指数
int mantisa; //尾数
}Float;
int main()
{
double a = 0.0001, b = 200000, c = a / b;
printf("%lf\n", c);
Float x = {-4, 1}, y = {5, 2}, z = {-5-5, 10/2}; // z = x / y
printf("%dE%d", z.mantisa, z.exponent);
return 0;
}
/*
0.000000
5E-10
*/
