Bits and Bytes Boolean Algebra (2.1.7--2.1.10) Boolean algebra Expressing in C.

Slides:



Advertisements
Similar presentations
CSCE 212 Computer Organization Lecture 2 Data Representation.
Advertisements

Bits and Bytes 4/2/2008 Topics Physics, transistors, Moore’s law Why bits? Representing information as bits Binary/Hexadecimal Byte representations »numbers.
Bits and Bytes CS 213 Aug. 27, 1998 Topics Why bits? Representing information as bits –Binary/Hexadecimal –Byte representations »numbers »characters and.
Bits and Bytes January 17, 2002 Topics Why bits? Representing information as bits –Binary/Hexadecimal –Byte representations »numbers »characters and strings.
Bits and Bytes Topics Physics, transistors, Moore’s law Why bits? Representing information as bits Binary/Hexadecimal Byte representations »numbers »characters.
1 CSE 20: Lecture 8 Boolean Postulates and Theorems CK Cheng 4/26/2011.
ICS 2005 Instructor: Peter A. Dinda TA: Bin Lin Recitation 2.
Bits and Bytes January 15, 2004 Topics Why bits? Representing information as bits Binary/Hexadecimal Byte representations »numbers »characters and strings.
Bits and Bytes Topics Why bits? Representing information as bits Binary/Hexadecimal Byte representations »numbers »characters and strings »Instructions.
February 4, 2003 CSCE 212 Computer Architecture Lecture 3 Representing Integers.
1 CSE 20: Lecture 7 Boolean Algebra CK Cheng 4/21/2011.
Fabián E. Bustamante, Spring 2007 Bits and Bytes Today Why bits? Binary/hexadecimal Byte representations Boolean algebra Expressing in C.
Real Numbers 1 Definition 2 Properties 3 Examples
Mathematical Properties Algebra I. Associative Property of Addition and Multiplication The associative property means that you will get the same result.
CS 270: Computer Organization Bits, Bytes, and Integers
Bits and Bytes Topics Representing information as bits Bit-level manipulations Boolean algebra Expressing in C.
Lecture 3: Computation and Representation CS 2011 Fall 2014, Dr. Rozier.
Bits and Bytes Topics Why bits? Tell me Representing information as bits Binary/Hexadecimal Byte representations »numbers »characters and strings »Instructions.
Logic Gates Shashidhara H S Dept. of ISE MSRIT. Basic Logic Design and Boolean Algebra GATES = basic digital building blocks which correspond to and perform.
Boolean Algebra & Logic Prepared by Dr P Marais (Modified by D Burford)
Boolean Logic and Circuits ELEC 311 Digital Logic and Circuits Dr. Ron Hayne Images Courtesy of Cengage Learning.
Bits, Bytes, and Integers Topics Representing information as bits Bit-level manipulations Boolean algebra Expressing in C Representations of Integers Basic.
Properties of Addition and Multiplication. Commutative Property In the sum you can add the numbers in any order. a+b = b+a In the product you can multiply.
Chapter 2 Guobao Jiang Outline 2.1 Information Storage 2.2 Integer Representations 2.3 Integer Arithmetic 2.4 Floating Point.
1 Saint Louis University Arithmetic and Bitwise Operations on Binary Data CSCI 224 / ECE 317: Computer Architecture Instructor: Prof. Jason Fritts Slides.
Bits and Bytes September 2, 2004 Topics Why bits? Representing information as bits Binary / Hexadecimal Byte representations »Numbers »Characters and strings.
– 1 – Number Systems Number of symbols = base of the system Most intuitive -- base 10 (decimal system) counting on fingertips symbols
Boolean Algebras Lecture 27 Section 5.3 Wed, Mar 7, 2007.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Logic and Boolean Algebra. Logic statements  Real life statements  “I use public transportation when the car is broken and I have to go to work”  “All.
BOOLEAN ALGEBRA Kamrul Ahsan Teacher of
Laws of Boolean Algebra Commutative Law Associative Law Distributive Law Identity Law De Morgan's Theorem.
(2 + 1) + 4 = 2 + (1 + 4) Associative Property of Addition.
Bits and Bytes Topics Why bits? Representing information as bits
PROPERTIES OF REAL NUMBERS. COMMUTATIVE PROPERTY OF ADDITION What it means We can add numbers in any order Numeric Example Algebraic Example
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Properties Objective: To use the properties of numbers. Do Now 1.) = 3.) ( 2  1 )  4 = 2.) =4.) 2  ( 1  4 ) =
by D. Fisher (2 + 1) + 4 = 2 + (1 + 4) Associative Property of Addition 1.
(2 + 1) + 4 = 2 + (1 + 4) Associative Property of Addition.
Axioms for Rational Numbers 9/14-9/15. Natural Numbers – Numbers used for counting: 1, 2, 3, and so on. Whole Numbers – Natural numbers and zero: 0, 1,
Carnegie Mellon Bits, Bytes, and Integers (1-2) /18-243: Introduction to Computer Systems 2 nd Lecture, 19 May 2011 Instructors: Gregory Kesden.
Boolean Algebras Lecture 24 Section 5.3 Wed, Mar 22, 2006.
1 Manipulating Information (1). 2 Outline Bit-level operations Suggested reading –2.1.7~
Properties of Algebra. 7 + ( ) = ( ) + 9.
Number Properties. Commutative Property of Addition Words: In a sum, you can add terms in any order. Numbers: 5 + (-6) Algebra: a + b b + a.
Hoda Roodaki Boolean Algebra Hoda Roodaki
Today’s Instructor: Randy Bryant
Properties of Operations
Commutative Property of Addition
Bits, Bytes, and Integers CSE 238/2038/2138: Systems Programming
Instructor: David Ferry
Boolean Algebra.
Representing Information
Boolean Algebra.
Bits and Bytes Topics Representing information as bits
Bits and Bytes Topics Representing information as bits
Bits and Bytes Boolean algebra Expressing in C
Bits and Bytes Topics Representing information as bits
Bits, Bytes, and Integers 2nd Lectures
Bits and Bytes Topics Representing information as bits
“The Class That Gives CMU Its Zip!”
Boolean Algebra Introduction CSCI 240
Memory, Data, & Addressing II CSE 351 Summer 2018
Bits and Bytes Topics Representing information as bits
Comp Org & Assembly Lang
Comp Org & Assembly Lang
Operations and Arithmetic
“The Class That Gives CMU Its Zip!”
“The Class That Gives CMU Its Zip!”
Lecture 2: Bits, Bytes, Ints
Presentation transcript:

Bits and Bytes Boolean Algebra ( ) Boolean algebra Expressing in C

Boolean Algebra Developed by George Boole in 19th Century – Algebraic representation of logic Encode “True” as 1 and “False” as 0And A&B = 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

– Commutativity A | B = B | AA + B = B + A A & B = B & AA * B = B * A – Associativity (A | B) | C = A | (B | C)(A + B) + C = A + (B + C) (A & B) & C = A & (B & C)(A * B) * C = A * (B * C) – Product distributes over sum A & (B | C) = (A & B) | (A & C)A * (B + C) = A * B + B * C – Sum and product identities A | 0 = AA + 0 = A A & 1 = AA * 1 = A – Zero is product annihilator A & 0 = 0A * 0 = 0 – Cancellation of negation ~ (~ A) = A– (– A) = A Boolean Algebra  Integer Ring

– Boolean: Sum distributes over product A | (B & C) = (A | B) & (A | C)A + (B * C)  (A + B) * (B + C) – Boolean: Idempotency A | A = AA + A  A “A is true” or “A is true” = “A is true” A & A = AA * A  A – Boolean: Absorption A | (A & B) = AA + (A * B)  A “A is true” or “A is true and B is true” = “A is true” A & (A | B) = AA * (A + B)  A – Boolean: Laws of Complements A | ~A = 1A + –A  1 “A is true” or “A is false” – Ring: Every element has additive inverse A | ~A  0A + –A = 0 Boolean Algebra  Integer Ring

Properties of & and ^ (Xor) Boolean Ring –  {0,1}, ^, &, , 0, 1  –Identical to integers mod 2 –  is identity operation:  (A) = A A ^ A = 0 PropertyBoolean Ring –Commutative sumA ^ B = B ^ A –Commutative productA & B = B & A –Associative sum(A ^ B) ^ C = A ^ (B ^ C) –Associative product(A & B) & C = A & (B & C) –Prod. over sumA & (B ^ C) = (A & B) ^ (B & C) –0 is sum identityA ^ 0 = A –1 is prod. identityA & 1 = A –0 is product annihilatorA & 0 = 0 –Additive inverseA ^ A = 0

General Boolean Algebras Operate on Bit Vectors –Operations applied bitwise All of the Properties of Boolean Algebra Apply & | ^ ~

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 Examples (Char data type) – ~0x41 --> 0xBE ~ > – ~0x00 --> 0xFF ~ > – 0x69 & 0x55 --> 0x & > – 0x69 | 0x55 --> 0x7D | >

Contrast: Logic Operations in C Contrast to Logical Operators – &&, ||, ! View 0 as “False” Anything nonzero as “True” Always return 0 or 1 Early termination Examples (char data type) – !0x41 --> 0x00 – !0x00 --> 0x01 – !!0x41 --> 0x01 – 0x69 && 0x55 --> 0x01 – 0x69 || 0x55 --> 0x01

Cool Stuff with Xor void funny(int *x, int *y) { *x = *x ^ *y; /* #1 */ *x = *x ^ *y; /* #1 */ *y = *x ^ *y; /* #2 */ *y = *x ^ *y; /* #2 */ *x = *x ^ *y; /* #3 */ *x = *x ^ *y; /* #3 */} –Bitwise Xor is form of addition –With extra property that every value is its own additive inverse A ^ A = 0 BA Begin BA^B 1 (A^B)^B = AA^B 2 A(A^B)^A = B 3 AB End *y*x