程序清单4.5_defines.c程序_《C Primer Plus》P67

// defines.cpp : 定义控制台应用程序的入口点。
//
/* defines.c -- 使用 limits.h 和 float.h 中定义的常量 */

/*
    时间:2018年06月12日 23:01:03
    代码:程序清单4.5_defines.c程序_《C Primer Plus》P67
    目的:初步了解 limits.h 和 float.h 中一些符号的常量
*/
#include "stdafx.h"
#include "limits.h"        // 整数限制
#include "float.h"        // 浮点数限制

int _tmain(int argc, _TCHAR* argv[])
{
    printf("Some number limits for this system: \n");
    printf("Biggest int: %d\n", INT_MAX);
    printf("Smallest unsigned long: %lld\n", LLONG_MIN);
    printf("One byte = %d bits on this systme\n", CHAR_BIT);
    printf("Largest double: %e\n", DBL_MAX);
    printf("Smallest normal float: %e\n", FLT_MIN);
    printf("float precision = %d digits\n", FLT_DIG);
    printf("float epsilon = %e\n", FLT_EPSILON);
    getchar();

    return 0;
}

/*
    在VS2010中运行结果:
------------------------------------------------
Some number limits for this system:
Biggest int: 2147483647
Smallest unsigned long: -9223372036854775808
One byte = 8 bits on this systme
Largest double: 1.797693e+308
Smallest normal float: 1.175494e-038
float precision = 6 digits
float epsilon = 1.192093e-007
------------------------------------------------
    google 翻译如下:

这个系统的一些数字限制:
最大的int:2147483647
最小的无符号long:-9223372036854775808
一个字节= 8位在这个系统上
最大双倍:1.797693e+308
最小正常浮动:1.175494e-038
浮点精度= 6位数
浮动epsilon = 1.192093e-007
------------------------------------------------
    总结:
        初步了解一些符号常量:
        FLT_DIG: float 类型的最少有效数字位数(十进制);
        FLT_EPSILON: 1.00和比1.00大的最小的 float 类
        型之间的差值;
------------------------------------------------

*/


猜你喜欢

转载自blog.51cto.com/13555061/2128668