http://bbs.csdn.net/topics/380028485

整型常量的类型是下列相应表中第一个能表示其值的类型:

int --> long int --> long long int

无后缀的十进制整数常量:int,long int,long long int
以字母u或U为后缀的十进制整型常量:unsigned int,unsigned long int,unsigned long long int

以字母l或L为后缀的十进制整型常量:long int,long long int
同时以字母u或U和字母l或L为后缀的十进制整型常量:unsigned long int,unsigned long long int

以字母ll或LL为后缀的十进制整型常量:long long int
同时以字母u或U和字母ll或LL为后缀的十进制整型常量:unsigned long long int

无后缀的八进制或十六进制常量:int,unsigned int,long int,unsigned long int,long long int,unsigned long long int
以字母u或U为后缀的八进制或十六进制常量:unsigned int,unsigned long int,unsigned long long int
以字母l或L为后缀的八进制或十六进制常量:long int,unsigned long int,long long int,unsigned long long int

同时以字母u或U和字母l或L为后缀的八进制或十六进制常量:unsigned long int,unsigned long long int
以字母ll或LL为后缀的八进制或十六进制常量:long long int,unsigned long long int

同时以字母u或U和字母ll或LL为后缀的八进制或十六进制常量:unsigned long long int

http://www.rapidtables.com/prog/cref/const.htm

Numbers characters and string constants.

See enum end const in data types page.

Data Type Constants

Syntax Description Example

0xhexnum

0Xhexnum

hexadecimal number int x=0x7FFF0000;

0 octnum

octal number int x=07654321;

num u

num U

unsigned integer number constant unsigned int x=1000U;

num l

num L

long integer number constant long x=-99999L;

num ul

num UL

unsigned long integer number constant unsigned long x=99999L;

num ll

num LL

long long  integer number constant long long x=-888888LL;

num ull

num ULL

unsigned long long integer number constant unsigned long long x=100ULL;

num f

num F

float number constant float x=0.005F;

num l

num L

long double number constant long double x=0.005L;

num exp

num exp

floating point exponent number constant double x=5.2E-3;

'char'

character constant char c='A';

"string"

string constant char name[6]="Hello";

http://stackoverflow.com/questions/7036056/what-do-0ll-or-0x0ul-mean

These are constants in C and C++.
The suffix LL means the constant is of type long long, and UL means unsigned long.

In general, each L or l represents a long and
each U or u represents anunsigned. So, e.g.

1uLL    // means the constant 1 with type unsigned long long.

This also applies to floating point numbers:

1.0f    // of type 'float'
1.0 // of type 'double'
.0L // of type 'long double'

and strings and characters, but they are prefixes:

 'A'   // of type 'char'
L'A' // of type 'wchar_t'
u'A' // of type 'char16_t' (C++0x only)
U'A' // of type 'char32_t' (C++0x only)

In C and C++ the integer constants are evaluated using their original type,
which can cause bugs due to integer overflow:

long long nanosec_wrong =  * ;
// ^ you'll get '-1295421440' since the constants are of type 'int'
// which is usually only 32-bit long, not big enough to hold the result. long long nanosec_correct = 1000000000LL *
// ^ you'll correctly get '600000000000' with this int secs = ;
long long nanosec_2 = 1000000000LL * secs;
// ^ use the '1000000000LL' to ensure the multiplication is done as 'long long's.

In Google Go, all integers are evaluated as big integers (no truncation happens),

var nanosec_correct int64 =  * 

and there is no "usual arithmetic promotion"

 var b int32 =
var a int64 = * b
// ^ cannot use 1000000000 * b (type int32) as type int64 in assignment

so the suffixes are not necessary.

C 常量的类型的更多相关文章

  1. ios swift 里面关于变量 常量 可选类型 控制流的一些心得

    //swift 里面没有头文件和实现文件.只有一个.swift文件 //swift 里面没有main的概念,程序从main.swift开始执行 //swift 每一条执行语句可以不用分号结束,多条语句 ...

  2. 【c++primer练习】 typedef与指针、常量和类型别名

    # c++primer 61页 typedef char* ptr ; cstr 是一个指向 char 的常量指针, 一种错误的理解是将语句等同于const char* ptr cstr; 但 ptr ...

  3. Java基础(变量数&常量&据类型&类型转换)

    什么是变量: 变量就是一个不固定的数值,它随时会改变,就像银行卡里存的钱一样会变动. 变量的格式:1  数据类型 变量名=变量值:  2  数据类型 变量名: 变量名=变量值: 变量的三大要素:1变量 ...

  4. C#中的常量、类型推断和作用域

    一.常量 常量是其值在使用过程中不会发生变化的变量.在声明和初始化变量时,在变量前面家关键字const,就可以把该变量指定为一个常量: const int a=100;//a的值将不可以改变 常量的特 ...

  5. swift语法之常量 变量 类型

    常量和变量: 在swift中声明变量或者声明常量的时候可以不用写变量或者常量类型 因为系统会自动推导出对应的类型. 变量:可以更改值 swift中每句代码后面不需要加 ; 号 var num = 5 ...

  6. Effective Objective-C 2.0 — 第四条:多用类型常量,少用#define预处理指令

    第四条:多用类型常量,少用#define预处理指令 使用#define 预处理的坏处:定义出来的常量没有类型信息,编译器只是会在编译前据此执行查找与替换操作.即使有人重新定义了常量值,编译器也不会产生 ...

  7. 第4条:多用类型常量,少用#define预处理指令

    定义常量的几种方式: 1.#define ANIMATION_DURAION 0.3         //定义了一个动画时长的常量, 预处理过程会把碰到的所有ANIMATION_DURAION一律替换 ...

  8. 【Go入门教程4】变量(var),常量(const),内置基础类型(Boolean、数值 byte,int,rune、字符串、错误类型),分组,iota枚举,array(数值),slice(切片),map(字典),make/new操作,零值

    这小节我们将要介绍如何定义变量.常量.Go 内置类型以及 Go 程序设计中的一些技巧. 定义变量 Go 语言里面定义变量有多种方式. 使用 var 关键字是 Go 最基本的定义变量方式,与 C 语言不 ...

  9. 多用类型常量,少用#define预处理指令

    摒弃: #define ANIMATION_DURATION 0.3   #define ERROR_MESSAGE @“ErrorMessage” 1)没有常量的类型信息 2)假设此指令声明在某个头 ...

随机推荐

  1. 常见四大类型视频接线DP、HDMI、DVI、VGA的比较

    如今是新的“视”界,生活中总与各种屏幕打交道,难免会遇到选择视频接线的问题,要想搞清楚这点,我们只要通过了解现今常用的几种视频接线就会有个大致的认识.   281VGA.DVI.HDMI三种视频信号接 ...

  2. java基础34 泛型的使用

    本文知识点(目录): 1.泛型的好处    2.泛型在集合中的常见应用(这里只用String类型举例)    3.在泛型中是不能使用基本数据类型,如果需要使用基本数据类型,那么就使用基本数据类型对应的 ...

  3. Elasticsearch零停机时间更新索引配置或迁移索引

    本文介绍Elasticsearch零宕机时间更新索引配置映射内容的方法,包括字段类型.分词器.分片数等.方法原理就是,利用别名机制,给索引配置别名,所有应用程序都通过别名访问索引.重建索引,通过索引原 ...

  4. 创建自己的maven模板

    概述 使用maven创建项目时,提供的基础的工程太简单不是想要的,并且创建过程很慢,使用起来体验不好.如果可以根据自己的需要,直接创建模板,然后进行类似项目拷贝的工作,那就完美.幸运的是,maven提 ...

  5. 微信小程序蓝牙模块

    蓝牙部分知识 关于Service: 每个设备包含有多个Service,每个Service对应一个uuid 关于Characteristic 每个Service包含多个Characteristic,每个 ...

  6. 判断一个字符是否为数字的两种方法(C/C++)

    在平时,我们经常遇见判断字符是否为数字这种题目,虽然感觉还是很简单,不过我是个更喜欢用函数的人,因为我觉得这样更便捷,所以我更推荐第二种方式. 1.直接判断 #include <stdio.h& ...

  7. **PHP转义Json里的特殊字符的函数

    http://www.banghui.org/11332.html 在给一个 App 做 API,从服务器端的 MySQL 取出数据,然后生成 JSON.数据中有个字段叫 content,里面保存了文 ...

  8. Java反射机制demo(四)—获取一个类的父类和实现的接口

    Java反射机制demo(四)—获取一个类的父类和实现的接口 1,Java反射机制得到一个类的父类 使用Class类中的getSuperClass()方法能够得到一个类的父类 如果此 Class 表示 ...

  9. Bipartite Graph hdu 5313 bitset 并查集 二分图

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=5313 题意: 给出n个顶点,m条边,问最多添加多少条边使之构成一个完全二分图 存储结构: bitset   ...

  10. gpfs 内核错误

    centos7.3安装旧的GPFS引发内核错误 没有关闭之前是可以查看到smap cat /proc/cpuinfo | grep smap 系统层关闭,也可以正常使用gpfs grubby --up ...