无符号整型 unsigned int、unsigned long、usigned long long、size_t 比较和格式控制
位数比较
由于数据的长度和平台相关,所以基于 64 位系统比较。
| Windows | Linux | |
|---|---|---|
| unsigned int | 32 bits/4294967295 | 32 bits |
| unsigned long | 32 bits | 64 bits/18446744073709551615 |
| unsigned long long | 64 bits | 64 bits |
| size_t | 32 bits | 64 bits |
可以看到,size_t 和 unsigned long 比较同步。另外 ssize_t 和 size_t 的关系就像 int 和 unsigned int 的关系。(参考1,参考2)
格式控制(printf)
| length | d i | u o x X | f F e E g G a A | c | s | p | n |
|---|---|---|---|---|---|---|---|
| (none) | int | unsigned int | double | int | char* | void* | int* |
| hh | signed char | unsigned char | signed char* | ||||
| h | short int | unsigned short int | short int* | ||||
| l | long int | unsigned long int | wint_t | wchar_t* | long int* | ||
| ll | long long int | unsigned long long int | long long int* | ||||
| j | intmax_t | uintmax_t | intmax_t* | ||||
| z | size_t | size_t | size_t* | ||||
| t | ptrdiff_t | ptrdiff_t | ptrdiff_t* | ||||
| L | long double |
(参考)
测试代码
#include <cstdio>
int main()
{
unsigned int ui = -1;
unsigned long ul = -1;
unsigned long long ull = -1;
size_t st = -1;
printf("ui=%u,ul=%lu,ull=%llu,st=%zu\n", ui, ul, ull, st);
return 0;
}
测试结果
Windows

Linux

无符号整型 unsigned int、unsigned long、usigned long long、size_t 比较和格式控制的更多相关文章
- 整型,长整型,无符号整型等 大端和小端(Big endian and Little endian)
一.大端和小端的问题 对于整型.长整型.无符号整型等数据类型,Big endian 认为第一个字节是最高位字节(按照从低地址到高地址的顺序存放数据的高位字节到低位字节):而 Little endian ...
- CoreSeek有符号整型
数据库status字段的值有:-1,0,1 设置过滤字段,发现sql_attr_uint不支持负数,后改用sql_attr_bigint sql_attr_bigint = status sql_at ...
- 整型:int
整型:int 整型变量的定义和输出 注意://short<=int<=long<=longlong 代码示例一: #include<stdio.h> int ma ...
- C语言之将无符号字符型转化为ascii码值
这个宏是在linux内核中获取的,主要的功能是能够将一个无符号字符型的参数转化为ASCII码值. ASCII : ASCII 编码里包括了128个字符.用 十进制 0 到 127 来表示 .那就对了 ...
- 2016年11月3日JS脚本简介数据类型: 1.整型:int 2.小数类型: float(单精度) double(双精度) decimal () 3.字符类型: chr 4.字符串类型:sting 5.日期时间:datetime 6.布尔型数据:bool 7.对象类型:object 8.二进制:binary 语言类型: 1.强类型语言:c++ c c# java 2.弱类型语
数据类型: 1.整型:int 2.小数类型: float(单精度) double(双精度) decimal () 3.字符类型: chr 4.字符串类型:sting 5.日期时间:datetime 6 ...
- Java and unsigned int, unsigned short, unsigned byte, unsigned long, etc. (Or rather, the lack thereof)
http://darksleep.com/player/JavaAndUnsignedTypes.html —————————————————————————————————————————————— ...
- Python入门篇-基础数据类型之整型(int),字符串(str),字节(bytes),列表(list)和切片(slice)
Python入门篇-基础数据类型之整型(int),字符串(str),字节(bytes),列表(list)和切片(slice) 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.Py ...
- 整型(int)转时间格式字符串及页面long型转时间格式字符串
1,如果是封装的整型的话需要在后台进行处理再返回页面 处理过程是这样的 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm ...
- C++ 无符号整型和整型的区别
在Win 7系统中,short 表示的范围为 - 32767到 32767,而无符号的short表示的范围为0 到 65535,其他类型的同理可推导出来,当然,仅当数字不为负的时候才使用无符号类型. ...
随机推荐
- swift函数的调用约定
The convention of the function, indicated by the attribute. This is similar to the language-level @c ...
- 转://Oracle补丁及opatch工具介绍
一. CPU(Critical Patch Update) 一个CPU内包含了对多个安全漏洞的修复,并且也包括相应必需的非安全漏洞的补丁.CPU是累积型的,只要安装最新发布的CPU即可,其中包括之前发 ...
- Excel中row函数的使用方法
1.row函数的含义 1 row函数的含义 返回所选择的某一个单元格的行数. END 2.row函数的语法格式 1 row函数的语法格式 =row(reference) 如果省略reference,则 ...
- Arduino IDE for ESP8266 项目云盒子(4)组网
- python opencv show图片,debug技巧
debug的时候可以直接把图片画出来debug. imshow函数就是python opencv的展示图片的函数,第一个是你要起的图片名,第二个是图片本身.waitKey函数是用来展示图片多久的,默认 ...
- all与any的用法
all函数:检测矩阵中是否全为非零元素 any函数:检测矩阵中是否有非零元素,如果有,则返回1,否则,返回0.用法和all一样 语法: B = all(A) B = all(A, dim) 复制代码 ...
- PAT A1145 Hashing - Average Search Time (25 分)——hash 散列的平方探查法
The task of this problem is simple: insert a sequence of distinct positive integers into a hash tabl ...
- PAT A1014 Waiting in Line (30 分)——队列
Suppose a bank has N windows open for service. There is a yellow line in front of the windows which ...
- ASP.NET ActiveMQ 消息队列
1.引入 2.发送消息 3.接收消息 概述:MQ消息存放在内存,重启后,消息丢失.接收后,消息丢失(只取一次),不取,一直在且速度快. 使用前:下载apache-activemq-5.15.2-bin ...
- 创建Web API并使用
昨晚有教一个网友在ASP.NET MVC里,创建Web API和在MVC视图中应用此API. 可以在ASP.NET MVC中,创建程序的model: namespace Insus.NET.Model ...