The integer promotion.
#include <stdlib.h>
#include <stdio.h>
#define PRINT_COMPARE_RESULT(a, b) \
if (a > b) { \
printf( #a " > " #b "\n"); \
} \
else if (a < b) { \
printf( #a " < " #b "\n"); \
} \
else { \
printf( #a " = " #b "\n" ); \
} int main()
{
int a = -;
unsigned short b = ;
unsigned int c = ; PRINT_COMPARE_RESULT(a,b);
PRINT_COMPARE_RESULT(a,c); return ;
}
The result is a > c and a < b.
Operands a that has signed integer type has rank less than the rank of the type of the operand c,so the a with signed integer type is converted the type of the c with unsigned integer type.The signed integer -1 is coverted to unsigned integer is 0xffffffff that is greater than the value 3 of unsigned integer c.However, the rank of a is greater than the rank of b that has unsigned short integer type,so the unsigned short integer type is converted to signed int type.So a < b.
The integer promotion.的更多相关文章
- 【C】 03 - 数据类型
程序说到底就是对数据的处理,所以首先要弄清楚需要处理哪些数据,计算机如何存储这些数据.C语言根据需要,抽象出了一些基本数据类型和衍生数据类型.这些可以满足大部分需求,更复杂的抽象数据类型亦可通过它们来 ...
- 消除第三方库moodycamel的编译器警告
在项目中需要引入第三方无锁队列,此处我选用的是moodycamel. 然而引入头文件编译之后,一直提示报错信息,需要专门针对此文件消除编译警告(本人使用GCC编译器). 在文件头处添加如下语句: #i ...
- C-类型转换(陷阱)
getchar() 返回值为int类型 1.自动类型转换(运算符两边变量类型不同时) 1).两个变量类型自动转换成一样的类型(会根据参数类型自动转换, 而不是直接位转换), 且运算结果也是转换后的类型 ...
- C/C++ 中的算术及其陷阱
目录 概述 C/C++ 整数的阴暗角落 整型字面量 整型提升与寻常算术转换 算术溢出检测 位运算技巧 总结 参考 概述 无符号数和有符号数是通用的计算机概念,具体到编程语言上则各有各的不同,程序员是解 ...
- [Linux] Linux C编程一站式学习 Part.2
C语言本质 计算机中数的表示 浮点数:符号位+指数部分(2的多少次方)+尾数部分(小数点后的数字) 用偏移的指数(Biased Exponent)表示负指数 正规化(Normalize):尾数部分最高 ...
- char、signed char、unsigned char的区别总结。
转载地址:http://hi.baidu.com/thewillreigns/blog/item/67e665c4296e69c038db492d.html char 和 unsigned char是 ...
- 洛谷P3605 [USACO17JAN] Promotion Counting 晋升者计数 [线段树合并]
题目传送门 Promotion Counting 题目描述 The cows have once again tried to form a startup company, failing to r ...
- [BZOJ4756][Usaco2017 Jan]Promotion Counting 树状数组
4756: [Usaco2017 Jan]Promotion Counting Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 305 Solved: ...
- LeetCode 7. Reverse Integer
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 Have you ...
随机推荐
- Leetcode: Design Snake Game
Design a Snake game that is played on a device with screen size = width x height. Play the game onli ...
- Windows Phone 五、配置存储
基本存储形式 本地设置:ApplicationData.Current.LocalSettings 漫游设置:ApplicationData.Current.RoamingSettings 支持的数据 ...
- JAVA 学习随笔 : JDK Enhancement Process JEP process
是时候寻找一个学习JAVA的路径了 ---- JDK Enhancement Process Oracle发布了JDK增强提案与路线图进程,目的在于鼓励OpenJDK提交者贡献点子和扩展以改进Open ...
- 【《zw版·Halcon与delphi系列原创教程》 zw_halcon人脸识别
[<zw版·Halcon与delphi系列原创教程>zw_halcon人脸识别 经常有用户问,halcon人脸识别方面的问题. 可能是cv在人脸识别.车牌识别方面的投入太多了. 其实,人脸 ...
- 二十四、JDK1.5新特性---泛型
由于本人认知有限,泛型在使用上没有太大压力,但是尚未具备详细介绍泛型的能力,因此本文只是粗略的描述泛型的相关知识,在以后的学习过程中会对这篇文章进行修改,希望这篇文章不会给读者带来迷惑,特此声明 什么 ...
- XE5 修复 安卓 输入法隐藏 后 无法退出的问题 3.2
欢迎到 ① FireMonkey[DELPHI XE5] 165232328 交流开发技术. (************************************************** ...
- 制作centos的U盘启动盘
制作centos的U盘启动盘比ubuntu麻烦一些,因为可能涉及到fat32文件格式不支持大于4G的文件存储的问题,而最新版本的centos就是大于4G的,所以就需要对U盘进行分区. 一个做主引导,一 ...
- 《C++ API设计》作者Martin Reddy访谈问题征集
Martin Reddy博士是软件行业的一名老兵,有着15年以上的从业经验,共撰写过40多篇论文,拥有3项软件专利,并与他人合著了Level of Detail for 3D Graphics.另外, ...
- 给linode 替换操作系统核心
1.Make sure your package repositories and installed packages are up to date by issuing the following ...
- GirdView 追忆学生时代的百思不得解
临近年关,越多越多的园友开始了对工作.生活的总结,以及对来年目标的确立.这很励志,人是一根能思想的苇草,想来想去,我实在没什么惊天地.泣鬼神的英勇事迹,16年毕业季,按部就班的在时间的马车上颠簸,阅读 ...