*每天学习c++一小时*-expressions, operations and statements

本文深入探讨C++中的表达式、运算符及语句,详解使用分号显示计数、字符串字面量中空白的重要性、跨行语句的插入技巧、前缀与后缀递增的区别,以及逻辑与位运算符的应用。通过具体示例,讲解位移运算、位集转换、按位逻辑运算,并对比不同位运算结果。

每天学习c++一小时-expressions, operations and statements

1.using count to display on the screen with semicolon “;” ending

2.whitespace is not visible to the compiler, but whitespace with string literals makes difference

3.inserting backslash() at the end to spread a statement over two lines

4.prefix ++number L-value is the incremented value VS postfix number++ L-value is the original number

5.NOT ! AND && OR ||

6.1000>>1 =0100 1000>>2 =00100
1000<<1 =10000 1000<<2 =100000

7.bitset<8> inputBits(number) means transforming number into 2-Bits

8.bitset<8> bitwiseNOT = (~inputNum);
bitset<8> bitwiseAND = (0x0F & inputNum);// 0x0F is hex for 0001111
bitset<8> bitwiseOR = (0x0F | inputNum);
~10110101 = 01001010
Logical AND, & with 00001111
0001111 & 10110101 = 00000101
Logical OR, | with 00001111
00001111 | 10110101 = 10111111
Logical XOR, ^ with 00001111
00001111 ^ 10110101 = 10111010

9.the result of shifting signed numbers is implementation dependent. On some compilers, most-significant-bit when shifted left is not assigned to the least-significant-bit; rather the latter is zero.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值