- 1、本文档共27页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
* * * * * * * * * * * * * * * * * * * * * * * * Compilers Autumn 2002 Compilers Autumn 2002 * Manipulating Information (1) * Outline Bit-level operations Suggested reading 2.1.7~2.1.10 * Boolean Algebra Developed by George Boole(1815-1864) Algebraic representation of logic Encode “True” as 1 Encode “False” as 0 Claude Shannon(1916–2001)founded the information theory made the connection between Boolean algebra and digital logic Plays a central role in the design and analysis of digital systems * Boolean Algebra And AB = 1 when both A=1 and B=1 Not ~A = 1 when A=0 Or A|B = 1 when either A=1 or B=1 Exclusive-Or (Xor) A^B = 1 when either A=1 or B=1, but not both * General Boolean Algebras Operate on Bit Vectors Operations applied bitwise | ^ ~ * General Boolean Algebras Representation of Sets Width w bit vector represents subsets of {0, …, w–1} aj = 1 if j ? A{ 0, 3, 5, 6 }{ 0, 2, 4, 6 } Intersection { 0, 6 } | Union { 0, 2, 3, 4, 5, 6 } ^ Symmetric difference { 2, 3, 4, 5 } ~Complement { 1, 3, 5, 7 } * RGB Color Model * RGB Color Model Cyan Magenta * RGB Color Model What would be the complement of each of the eight colors listed above? The complement of a color is formed by turning off the lights that are on and turning on the lights that are off Describe the effect of applying Boolean operations on the following colors: Blue | Green = Yellow Cyan = Red ^ Magenta = * Bit-Level Operations in C Operations , |, ~, ^ Available in C Apply to any “integral” data type long, int, short, char View arguments as bit vectors Arguments applied bit-wise * Bit-Level Operations in C ~0x41 0xBE ~0x00 0xFF 0x69 0x55 0X41 0x69 | 0x55 0x7D ~0100 0001 1011 1110 ~0000 0000 1111 1111 0110 1001 0101 0101 0100 0001 0110 1001 | 0101 0101 0111 1101 * Cool Stuff with Xor Bitwise Xor is form
文档评论(0)