CS33-0

CS33-0 - CS 33: Computer Organization Topic 0 C+ Bit...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 33: Computer Organization Topic 0: C++ Bit Operations 9/2008 John A. Rohr All Rights Reserved JAR 0-1 CS 33: Computer Organization Topic 0 C++ Bit Operations
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 33: Computer Organization Topic 0: C++ Bit Operations 9/2008 John A. Rohr All Rights Reserved JAR 0-2 C++ Bit Operations << Shift Left
Background image of page 2
CS 33: Computer Organization Topic 0: C++ Bit Operations 9/2008 John A. Rohr All Rights Reserved JAR 0-3 Shift Left << Operator Use with cout is overloaded Original definition is left shift Moves bits left in a word Logical Shift: Inserts zeros as low bits Arithmetic shift is same as logical shift (Multiply by 2)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 33: Computer Organization Topic 0: C++ Bit Operations 9/2008 John A. Rohr All Rights Reserved JAR 0-4 Shift Left Examples • 1011 0111 2 << 1 0110 1110 2 • 1011 0111 2 << 2 1101 1100 2 • 1011 0111 2 << 3 1011 1000 2 • 1011 0111 2 << 4 0111 0000 2 • 1011 0111 2 << 5 1110 0000 2 • 1011 0111 2 << 6 1100 0000 2 • 1011 0111 2 << 7 1000 0000 2 • 1011 0111 2 << 8 0000 0000 2
Background image of page 4
CS 33: Computer Organization Topic 0: C++ Bit Operations 9/2008 John A. Rohr All Rights Reserved JAR 0-5 Shift Left Practice • 1110 0100 2 << 2
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 33: Computer Organization Topic 0: C++ Bit Operations 9/2008 John A. Rohr All Rights Reserved JAR 0-6 Shift Left Practice • 1110 0100 2 << 2 1001 0000 2
Background image of page 6
CS 33: Computer Organization Topic 0: C++ Bit Operations 9/2008 John A. Rohr All Rights Reserved JAR 0-7 Shift Left Practice • 0001 0110 2 << 3
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 33: Computer Organization Topic 0: C++ Bit Operations 9/2008 John A. Rohr All Rights Reserved JAR 0-8 Shift Left Practice • 0001 0110 2 << 3 1011 0000 2
Background image of page 8
CS 33: Computer Organization Topic 0: C++ Bit Operations 9/2008 John A. Rohr All Rights Reserved JAR 0-9 C++ Bit Operations << Shift Left >> Shift Right
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 33: Computer Organization Topic 0: C++ Bit Operations 9/2008 John A. Rohr All Rights Reserved JAR 0-10 Shift Right >> Operator Use with cin is overloaded Original definition is right shift Moves bits right in a word Logical Shift (Unsigned variables): Inserts zeros as high bits Arithmetic Shift (Signed variables): Inserts sign bits as high bits (Divide by 2)
Background image of page 10
CS 33: Computer Organization Topic 0: C++ Bit Operations 9/2008 John A. Rohr All Rights Reserved JAR 0-11 Shift Right (Logical) Examples • 0101 0111 2 >> UNSIGNED 1 0010 1011 2 • 0101 0111 2 >> UNSIGNED 2 0001 0101 2 • 0101 0111 2 >> UNSIGNED 3 0000 1010 2 • 0101 0111 2 >> UNSIGNED 4 0000 0101 2 • 0101 0111 2 >> UNSIGNED 5 0000 0010 2 • 0101 0111 2 >> UNSIGNED 6 0000 0001 2 • 0101 0111 2 >> UNSIGNED 7 0000 0000 2 • 0101 0111 2 >> UNSIGNED 8 0000 0000 2
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS 33: Computer Organization Topic 0: C++ Bit Operations 9/2008 John A. Rohr All Rights Reserved JAR 0-12 Shift Right (Logical) Examples • 1011 0111 2 >> UNSIGNED 1 0101 1011 2 • 1011 0111 2 >> UNSIGNED 2 0010 1101 2 • 1011 0111 2 >> UNSIGNED 3 0001 0110
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 77

CS33-0 - CS 33: Computer Organization Topic 0 C+ Bit...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online