#include <climits>

C++标准库整数类型常量介绍

<climits> 是 C++ 标准库中的一个头文件,提供了与整数类型相关的限制和特性。它定义了一组常量,描述了各种整数类型(如 charintlong 等)的最小值、最大值和其他相关属性。这些常量来自 C 标准库的 <limits.h> 头文件。

// -*- C++ -*- forwarding header.

// Copyright (C) 1997-2020 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file include/climits
 *  This is a Standard C++ Library file.  You should @c \#include this file
 *  in your programs, rather than any of the @a *.h implementation files.
 *
 *  This is the C++ version of the Standard C Library header @c limits.h,
 *  and its contents are (mostly) the same as that header, but are all
 *  contained in the namespace @c std (except for names which are defined
 *  as macros in C).
 */

//
// ISO C++ 14882: 18.2.2  Implementation properties: C library
//

#pragma GCC system_header

#include <bits/c++config.h>
#include <limits.h>

#ifndef _GLIBCXX_CLIMITS
#define _GLIBCXX_CLIMITS 1

#ifndef LLONG_MIN
#define LLONG_MIN (-__LONG_LONG_MAX__ - 1)
#endif

#ifndef LLONG_MAX
#define LLONG_MAX __LONG_LONG_MAX__
#endif

#ifndef ULLONG_MAX
#define ULLONG_MAX (__LONG_LONG_MAX__ * 2ULL + 1)
#endif

#endif

<climits> 提供的常量

这些常量描述了不同整数类型在特定平台上的特性。以下是一些常用的常量:

1. 字符类型

  • CHAR_BITchar 类型的位数(通常为 8)。
  • CHAR_MINchar 类型的最小值。
  • CHAR_MAXchar 类型的最大值。
  • SCHAR_MIN:有符号 char 类型的最小值。
  • SCHAR_MAX:有符号 char 类型的最大值。
  • UCHAR_MAX:无符号 char 类型的最大值。

2. 短整型

  • SHRT_MINshort 类型的最小值。
  • SHRT_MAXshort 类型的最大值。
  • USHRT_MAX:无符号 short 类型的最大值。

3. 整型

  • INT_MINint 类型的最小值。
  • INT_MAXint 类型的最大值。
  • UINT_MAX:无符号 int 类型的最大值。

4. 长整型

  • LONG_MINlong 类型的最小值。
  • LONG_MAXlong 类型的最大值。
  • ULONG_MAX:无符号 long 类型的最大值。

5. 长长整型

  • LLONG_MINlong long 类型的最小值。
  • LLONG_MAXlong long 类型的最大值。
  • ULLONG_MAX:无符号 long long 类型的最大值。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值