设为首页 加入收藏

TOP

2.2 Literal Constants (2)
2013-10-07 15:25:00 来源: 作者: 【 】 浏览:68
Tags:2.2 Literal Constants

Rules for Integer Literals

We can write a literal integer constant using one of three notations: decimal, octal, or hexadecimal. These notations, of course, do not change the bit representation of the value, which is always binary. For example, we can write the value 20 in any of the following three ways:

  1. 20 // decimal  
  2. 024 // octal  
  3. 0x14 // hexadecimal 

Literal integer constants that begin with a leading 0 (zero) are interpreted as octal; those that begin with either 0x or 0X are interpreted as hexadecimal.

根据语法来看,0 其实是个八进制数。

By default, the type of a literal integer constant is either int or long. The
precise type depends on the value of the literal—values that fit in an int are type

EXERCISES SECTION 2.1.2

Exercise 2.1: What is the difference between an int, a long, and a short value

Exercise 2.2: What is the difference between an unsigned and a signed type

Exercise 2.3: If a short on a given machine has 16 bits then what is the largest number that can be assigned to a short To an unsigned short

Exercise 2.4: What value is assigned if we assign 100,000 to a 16-bit unsigned short What value is assigned if we assign 100,000 to a plain 16-bit short

Exercise 2.5: What is the difference between a float and a double

Exercise 2.6: To calculate amortgage payment, what types would you use for the rate,principal, and payment Explain why you selected each type.

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇2.2 Literal Constants (3) 下一篇5.12.3 Other Implicit Conversio..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·C语言结构体怎么直接 (2025-12-24 17:19:44)
·为什么指针作为c语言 (2025-12-24 17:19:41)
·如何较为深入的理解c (2025-12-24 17:19:38)
·Announcing October (2025-12-24 15:18:16)
·MySQL有什么推荐的学 (2025-12-24 15:18:13)