广告合作
  • 今日头条

    今日头条

  • 百度一下

    百度一下,你就知道

  • 新浪网

    新浪网 - 提供新闻线索,重大新闻爆料

  • 搜狐

    搜狐

  • 豆瓣

    豆瓣

  • 百度贴吧

    百度贴吧——全球领先的中文社区

  • 首页 尚未审核订阅工具 订阅

    c语言的极限值的问题

    来源:网络收集  点击:  时间:2024-08-04
    【导读】:
    要在c语言使用极限值首先使用limits.h定义的符号表示每种类型的极限值float.h头文件定义了表示浮点数的符号工具/原料morec语言基础方法/步骤1/3分步阅读

    类型 下限 上限

    char CHAR_MIN CHAR_MAX

    short SHRT_MIN SHRT_MAX

    int INT_MIN INT_MAX

    long LONG_MIN LONG_MAX

    long long LLONG_MIN LLONG_MAX

    无符号下限是0 UCHAR_MAX USHRT_MAX U INT_MAX ULONG_MAX ULLONG_MAX

    例如 int number = INT_MAX ;

    2/3

    float.h头文件定义了表示浮点数的符号

    类型 下限 上限

    float FLT_MIN FLT_MAX

    double DBL_MAX DBL_MAX

    long double LDBL_MIN LDBL_MAX

    3/3

    例子:

    /* Program 2.11 Finding the limits */

    #include stdio.h /* For command line input and output */

    #include limits.h /* For limits on integer types */

    #include float.h /* For limits on floating-point types */

    int main(void)

    {

    printf(Variables of type char store values from %d to %d,

    CHAR_MIN, CHAR_MAX);

    printf(\nVariables of type unsigned char store values from 0 to %u,

    UCHAR_MAX);

    printf(\nVariables of type short store values from %d to %d,

    SHRT_MIN, SHRT_MAX);

    printf(\nVariables of type unsigned short store values from 0 to %u,

    USHRT_MAX);

    printf(\nVariables of type int store values from %d to %d, INT_MIN, INT_MAX);

    printf(\nVariables of type unsigned int store values from 0 to %u, UINT_MAX);

    printf(\nVariables of type long store values from %ld to %ld,

    LONG_MIN, LONG_MAX);

    printf(\nVariables of type unsigned long store values from 0 to %lu,

    ULONG_MAX);

    printf(\nVariables of type long long store values from %lld to %lld,

    LLONG_MIN, LLONG_MAX);

    printf(\nVariables of type unsigned long long store values from 0 to %llu,

    ULLONG_MAX);

    printf(\n\nThe size of the smallest non-zero value of type float is %.3e,

    FLT_MIN);

    printf(\nThe size of the largest value of type float is %.3e, FLT_MAX);

    printf(\nThe size of the smallest non-zero value of type double is %.3e,

    DBL_MIN);

    printf(\nThe size of the largest value of type double is %.3e, DBL_MAX);

    printf(\nThe size of the smallest non-zero value of type long double is %.3Le,

    LDBL_MIN);

    printf(\nThe size of the largest value of type long double is %.3Le\n,

    LDBL_MAX);

    printf(\nVariables of type float provide %u decimal digits precision.,

    FLT_DIG);

    printf(\nVariables of type double provide %u decimal digits precision.,

    DBL_DIG);

    printf(\nVariables of type long double provide %u decimal digits precision.,

    LDBL_DIG);

    return 0;

    }

    摘自《C语言入门经典》第4版

    注意事项

    点个赞吧

    本文关键词:

    版权声明:

    1、本文系转载,版权归原作者所有,旨在传递信息,不代表看本站的观点和立场。

    2、本站仅提供信息发布平台,不承担相关法律责任。

    3、若侵犯您的版权或隐私,请联系本站管理员删除。

    4、文章链接:http://www.1haoku.cn/art_1060298.html

    相关资讯

    ©2019-2020 http://www.1haoku.cn/ 国ICP备20009186号05-06 21:58:26  耗时:0.025
    0.0252s