当前位置:网站首页>Integer overflow and printing
Integer overflow and printing
2022-07-29 05:28:00 【Ryan fitter】
Integer overflow and printing
%u Description display unsigned int Type value
#include <stdio.h>
int main(void)
{
int i = 2147483647;
unsigned int j = 4294967295;
printf("%d %d %d\n",i,i+1,i+2);
printf("%u %u %u\n",j,j+1,j+2);
return 0;
}
Output structure
2147483647 -2147483648 -2147483647
4294967295 0 1
Print short、long、long long、unsigned type
%ld For printing long Type value
%lx Used to print in hexadecimal format long Type value
%lo Used to print in octal format long Type value
%hd Indicates display in decimal short Type integer
%ho Indicates that it is displayed in octal short Type integer
%lu Means to print unsigned long Type value
%lld It means signed long long Type value
%llu To represent an unsigned long long Type value
#include <stdio.h>
int main(void)
{
unsigned int un = 300000000;
short end = 200;
long big = 65537;
long long verybig = 12345678908642;
printf("un = %u and not %d\n",un,un);
printf("end = %hd and %d\n",end,end);
printf("big = %ld and not %hd\n",big,big);
printf("verybig = %lld and not %ld\n",verybig,verybig);
return 0;
}
Running results
un = 3000000000 and not -1294967296
end = 200 and 200
big = 65537 and not 1
verybig = 12345678908642 and not 194289938
This output can only have the following results in a specific system
边栏推荐
猜你喜欢
365天挑战LeetCode1000题——Day 040 设计跳表 + 避免洪水泛滥 + 查找大小为 M 的最新分组 + 销售价值减少的颜色球
·来一篇编程之路的自我介绍吧·
Occt learning 001 - Introduction
365 day challenge leetcode 1000 questions - day 040 design jump table + avoid flooding + find the latest grouping with size M + color ball with reduced sales value
C language handwritten qq-ai version
Come on! See how Clickhouse, which has risen 16 places a year, can be implemented in jd.com
Vs code的安装步骤及环境配置
【剑指offer】— 详解库函数atoi以及模拟实现atoi函数
C语言数组入门到精通(数组精讲)
预约中,2022京东云产业融合新品发布会线上开启
随机推荐
[event preview] cloud development, efficient and intelligent - the second Alibaba cloud ECS cloudbuild developer competition is about to start
适创科技以云仿真平台,支持“中国智造”升级
NVIDIA Zhou Xijian: the last mile from design to digital marketing
预约中,2022京东云产业融合新品发布会线上开启
321,京东言犀×NLPCC 2022挑战赛开赛!
365天挑战LeetCode1000题——Day 038 公交站间的距离 + 基于时间的键值存储 + 转变数组后最接近目标值的数组和 + 有界数组中指定下标处的最大值
Cryengine3 debugging shader method
京东云金秋上云特惠进行中!扫码参与活动
Cmu15-213 malloc lab experiment record
In depth analysis of common cross end technology stacks of app
2022数学建模竞赛暑期培训讲座——最优化方法:目标规划
D3d Shader Instruction
Together with digital people, digital space and XR platform, Alibaba cloud and its partners jointly build a "new vision"
Helm chart for Kubernetes
阿里云张新涛:异构计算为数字经济提供澎湃动力
365天挑战LeetCode1000题——Day 040 设计跳表 + 避免洪水泛滥 + 查找大小为 M 的最新分组 + 销售价值减少的颜色球
365 day challenge leetcode 1000 questions - day 039 full binary tree inserter + find peak II + snapshot array
321, Jingdong Yanxi × Nlpcc 2022 challenge starts!
C language one-dimensional array
vim编辑器使用