long long

基本数据类型

目标编译器: x86_64-linux-gnu

-
整数类型等价类型占用字节数
shortshort int2 bytes
signed short
signed short int
unsigned shortunsigned short int2 bytes
unsigned short int
intint4 bytes
signed
signed int
unsignedunsigned int4 bytes
unsigned int
longlong int8 bytes
long int
signed long
signed long int
unsigned longunsigned long int8 bytes
unsigned long int
long longlong long int8 bytes
long long int
signed long long
signed long long int
unsigned long longunsigned long long int8 bytes
unsigned long long int
  • 可以观察到在我的编译器上, long 与long long 都是占用8个字节

long long 取值范围

头文件中与long long相关3个宏

  • LLONG_MIN
  • LLONG_MAX
  • ULLONG_MAX(无符号超长整型最小值为0)
#include <iostream>
#include <climits>
int main() {
    long long longlongTest1 = 1;
    long long int longlongTest2 = 2;
    signed long long int longlongTest3 = 3;
    std::cout << sizeof(longlongTest1) << sizeof(longlongTest2) << sizeof(longlongTest3) << std::endl;

    std::cout << "long long  min" << LLONG_MIN << " " << std::hex << LLONG_MIN << std::endl;
    std::cout << "long long  max" << LLONG_MAX << " " << std::hex << LLONG_MAX << std::endl;
    std::cout << "unsigned long long  max" << ULLONG_MAX << " " << std::hex << ULLONG_MAX << std::endl;
}

输出结果:

long long  min-9223372036854775808 8000000000000000
long long  max7fffffffffffffff 7fffffffffffffff
unsigned long long  maxffffffffffffffff ffffffffffffffff
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值