What is the type of a constant in C? (U, UL, ULL, L, F)

Copied from here.

When we write expressions like this in C:

bool b = 1234567890 > 09876;

What are the types of those constants? The number 1234567890 - what is its type? How does C represent it when compiling it? The C Programming Language says:

An integer constant like 1234 is an int. A long constant is written with a terminal l (ell) or L, as in 123456789L; an integer constant too big to fit into an int will also be taken as a long. Unsigned constants are written with a terminal u or U, and the suffix ul or UL indicates unsigned long.

Floating-point constants contain a decimal point (123.4) or an exponent (1e-2) or both; their type is double, unless suffixed. The suffixes f or F indicate a float constant; l or L indicate a long double.

Here are some examples:

0                       // int
0l                      // long
1234                    // int
1234L                   // long
0ul                     // unsigned long
0u                      // unsigned int
2147483647              // int (just)
2147483648              // long
2147483647u             // unsigned int
2147483648u             // unsigned long (but could have fitted into an unsigned int)
0x0101010101010101ULL   // unsigned long long
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值