当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


C++ LONG_MIN用法及代码示例


C++ LONG_MIN 宏常量

LONG_MIN 常量是在 climits 头文件中定义的宏常量,用于获取 long int 对象的最小值,返回 long int 对象可以存储的最小值,即 -9223372036854775808(在 32 位编译器上) .

注意:

  • 实际值取决于编译器架构或库实现。
  • 我们也可以使用<limits.h>头文件而不是<climits>两个库中都定义了作为 LONG_MIN 常量的头文件。

LONG_MIN 常量的语法:

    LONG_MIN

例:

    Constant call:
    cout << LONG_MIN;

    Output:
    -9223372036854775808

用于演示带有 climits 标头的 LONG_MIN 常量示例的 C++ 代码

// C++ code to demonstrate example of 
// LONG_MIN constant with climits header
#include<iostream>
#include<climits>
using namespace std;

int main()
{
   //prinitng the value of LONG_MIN
    cout<<"LONG_MIN:"<<LONG_MIN<<endl;
    return 0;
}

输出

LONG_MIN:-9223372036854775808

用limits.h头文件演示LONG_MIN常量示例的C++代码

// C++ code to demonstrate example of 
// LONG_MIN constant with <limits.h> header file
#include<iostream>
#include<limits.h>
using namespace std;

int main()
{
   //prinitng the value of LONG_MIN
    cout<<"LONG_MIN:"<<LONG_MIN<<endl;
    return 0;
}

输出

LONG_MIN:-9223372036854775808


相关用法


注:本文由纯净天空筛选整理自 LONG_MIN constant with example in C++。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。