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: Concatenated Words
Given a list of words, please write a program that returns all concatenated words in the given list ...
- 关于Java内存模型的解读
运行时数据区域 运行时数据区包括以下五大部分:方法区.堆.虚拟机栈.本地方法栈.程序计数器.其中,方法区和堆是由所有线程共享的数据区,其他区域是线程隔离的数据区. 程序计数器: 程序计数器是一块较小的 ...
- 怎样设置才能允许外网访问MySQL
1.将本地数据库的user表的第一条记录的host数据改为%,或者用update user set host='%' where user='root'; 2.用MySQL的命令行客户端操作如下步骤: ...
- React 入门实例教程(转载)
本人转载自: React 入门实例教程
- 模拟apache commons dbutils 实现自己的BeanListHandler(回调应用)
首先dbcp相关的jar包和MySQL的驱动包导入到项目中. dbcp.properties配置文件如下,并放到项目根目录下. driverClassName=com.mysql.jdbc.Drive ...
- 【转载】调试利器 autoexp.dat
转载:http://www.cppblog.com/flyinghare/archive/2010/09/27/127836.html autoexp.dat入门(调试时自定义变量显示) VC在调试状 ...
- Thinkphp:有你真好
ThinkPHP是为了简化企业级应用开发和敏捷WEB应用开发而诞生的.最早诞生于2006年初,2007年元旦正式更名为ThinkPHP,并且遵循Apache2开源协议发布.ThinkPHP从诞生以来一 ...
- MiniUI中DataGrid数据的载入
本文将介绍一下,在ASP.NET MVC环境下,如何用Jquery MiniUI中的Datagrid控件载入数据. 1.效果展示: 2.具体步骤: 1> 既然是在MVC里,那我们的界面自然选择 ...
- 在.NET中使用JQuery 选择器精确提取网页内容
1. 前言 相信很多人做开发时都有过这样的需求:从网页中准确提取所需的内容.思前想后,方法无非是以下几种:(本人经验尚浅,有更好的方法还请大家指点) 1. 使用正则表达式匹配所需元素.(缺点:同类型的 ...
- Weblogic的架构
WebLogic管理控制台 WebLogic服务器提供了一个健壮的基于Web 的工具——管理控制台,它是执行上述任务的主要工具.通过管理控制台,你可以访问WebLogic管理服务.管理服务实现了 S ...