By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Slides:



Advertisements
Similar presentations
Intro to CS – Honors I Representing Numbers GEORGIOS PORTOKALIDIS
Advertisements

Fixed Point Numbers The binary integer arithmetic you are used to is known by the more general term of Fixed Point arithmetic. Fixed Point means that we.
Lecture #9 EGR 277 – Digital Logic
ICS312 Set 2 Representation of Numbers and Characters.
Introduction to Computers and Programming Lecture 7:
Kavita Hatwal Fall The decimal system, also called the base 10 number system is based on ten numbers: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. All the numbers.
Review Two’s complement
CS 3850 Lecture 5 Operators. 5.1 Binary Arithmetic Operators Binary arithmetic operators operate on two operands. Register and net (wire) operands are.
Bit Operations C is well suited to system programming because it contains operators that can manipulate data at the bit level –Example: The Internet requires.
A bit can have one of two values: 0 or 1. The C language provides four operators that can be used to perform bitwise operations on the individual bits.
Chapter 1 Number Systems and Codes William Kleitz Digital Electronics with VHDL, Quartus® II Version Copyright ©2006 by Pearson Education, Inc. Upper Saddle.
Computer Science 101 Number Systems. Humans Decimal Numbers (base 10) Decimal Numbers (base 10) Sign-Magnitude (-324) Sign-Magnitude (-324) Decimal Fractions.
4 Operations On Data Foundations of Computer Science ã Cengage Learning.
Binary Representation - Shortcuts n Negation x + x = 1111…1111 two = -1 (in 2’s complement) Therefore, -x = x + 1 n Sign Extension o Positive numbers :
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
Summer 2014 Chapter 1: Basic Concepts. Irvine, Kip R. Assembly Language for Intel-Based Computers 6/e, Chapter Overview Welcome to Assembly Language.
 Input and Output Functions Input and Output Functions  OperatorsOperators Arithmetic Operators Assignment Operators Relational Operators Logical Operators.
EX_01.1/46 Numeric Systems. EX_01.2/46 Overview Numeric systems – general, Binary numbers, Octal numbers, Hexadecimal system, Data units, ASCII code,
ICS312 Set 1 Representation of Numbers and Characters.
Information Representation. Digital Hardware Systems Digital Systems Digital vs. Analog Waveforms Analog: values vary over a broad range continuously.
10-Sep Fall 2001: copyright ©T. Pearce, D. Hutchinson, L. Marshall Sept Representing Information in Computers:  numbers: counting numbers,
Bit Manipulation when every bit counts. Questions on Bit Manipulation l what is the motivation for bit manipulation l what is the binary, hexadecimal,
CH2 – Using Data. Constant Something which cannot be changed Data Type Format and size of a data item Intrinsic Data Types Pg. 47 – Table 2-1 Basic ones.
1 DLD Lecture 18 Recap. 2 Recap °Number System/Inter-conversion, Complements °Boolean Algebra °More Logic Functions: NAND, NOR, XOR °Minimization with.
Chapter 2: Using Data.
Basic Operators. What is an operator? using expression is equal to 9. Here, 4 and 5 are called operands and + is the operator Python language supports.
Number systems, Operations, and Codes
Numbering System Base Conversion. Number systems Decimal – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Binary – 0, 1 Octal – 0, 1, 2, 3, 4, 5, 6, 7 Hexadecimal system.
Number System. Number Systems Important Number systems – Decimal – Binary – Hexadecimal.
CMSC 104, Lecture 051 Binary / Hex Binary and Hex The number systems of Computer Science.
Bitwise Operators Fall 2008 Dr. David A. Gaitros
Arithmetic Logic Unit (ALU) Anna Kurek CS 147 Spring 2008.
Bit Operations Horton pp Why we need to work with bits Sometimes one bit is enough to store your data: say the gender of the student (e.g. 0.
AP Computer Science A – Healdsburg High School 1 Unit 1 - Binary Numbers - Hexadecimal Numbers.
Computer Architecture EKT 422
Binary01.ppt Decimal Decimal: Base 10 means 10 Unique numerical digits ,00010,000 Weight Positions 3,
UniMAP Sem2-10/11 DKT121: Fundamental of Computer Programming1 Number Systems and Bitwise Operation.
Introduction to Microprocessors Chapter 2. Decimal or Base 10 Numbers  Have ten different digits (0-9)  It is a weighted number system. Each position.
Computers and Math Binary, Hex, and Decimal Oh My Copyright © Texas Education Agency, All rights reserved.1.
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 2A Reading, Processing and Displaying Data (Concepts)
CSE 351 Number Representation & Operators Section 2 October 8, 2015.
School of Computer and Communication Engineering, UniMAP Mohd ridzuan mohd nor DKT 122/3 - DIGITAL SYSTEM I Chapter.
CHAPTER 3: Number Systems
By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)
CSE 351 Number Representation. Number Bases Any numerical value can be represented as a linear combination of powers of n, where n is an integer greater.
By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)
Arithmetic Chapter 4 Subject: Digital System Year: 2009.
The Hexadecimal System is base 16. It is a shorthand method for representing the 8-bit bytes that are stored in the computer system. This system was chosen.
CMSC 1041 Binary / Hex Binary and Hex The number systems of Computer Science.
Two’s Complement The language of machines, part II.
Binary a. express numbers in binary, binary-coded decimal (BCD), octal and hexadecimal;
Computer Maintenance Numbering Systems Copyright © Texas Education Agency, All rights reserved.1.
Programmable Logic Controller
Computer Maintenance Numbering Systems Trade & Industrial Education
CSE 220 – C Programming Expressions.
Instructor: David Ferry
Number Systems and Bitwise Operation
Fundamentals & Ethics of Information Systems IS 201
University of Gujrat Department of Computer Science
Lecture 5 from (Chapter 4, pages 73 to 96)
Bits, Bytes, and Integers 2nd Lectures
13 Digital Logic Circuits.
Bitwise Operators.
Module 10 Operations on Bits
Chapter 10 Instruction Sets: Characteristics and Functions
Presentation transcript:

By Anand George SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Binary Numbers  The numbers we use in our daily life are called 10 based numerals.  For example number 348 is equal to (3 x 100) + (4 x 10) + 8  While humans use 10 based numerals computers use 2 based numerals which as only 1 and 0 s in any number. SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Demo  10 based numerals and  2 based numeral in calc SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Some Mapping of 10 based Numerals and 2 based Numerals. 10 based number2 base equivalent SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Some jargons  One digit of 2 based numeral is called a ‘bit’.  8 bits gives a byte  2 bytes or 16 bits give a word.  4 bytes or 32 bit gives a dword or doubleword. SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Some facts  Any number can be expressed in 2 based numeral.  A 2 based number of n digits can hold a number which has max value 2^n - 1 ( 2 to power n ) – 1.  Everything you see or deal with in a computer – programs, video, music, your facebook page…. name it..all 1s and 0s…which is a 2 based number or collection of 2 based numbers.  What makes the difference is the way different programs interpret the binary number. For example your facebook page is a big binary number which is interpreted by your browser as a web page and display it as a web page. Same big binary number can be something else to some other program or piece of code. SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Digital Operations on 2 based numbers.  We do operations like addition, subtraction etc which decimal or 10 based numerals in a daily bases.  2 based numerals also has all those operations.  2 based numeral has some additional operations as well.  AND, NOT, OR, NOR, XOR, Left Shift, Right Shift etc. SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

AND operation Input operand 1Input operand 2AND Output SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

OR Input operand 1Input operand 2OR Output SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Exclusive OR ( ExOR ) Input operand 1Input operand 2ExOR Output SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

NOT or Ones complement ( unary operator as there is only one operand) Input operand 1NOT Output SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Shift operations  Left Shift  Right Shift OperationValue Initial0001 Left Shift by 1 bit0010 Left Shift by 1 bit0100 Left Shift by 1 bit1000 OperationValue Initial1100 Right Shift by 1 bit0110 Right Shift by 1 bit0011 Right Shift by 1 bit0001 SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Demo  Visual Studio  Bitwise operation In C.  OR |  AND &  NOT ^  Left Shift  Right Shift SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Operations ( cont )  These operations has some special physical means when it comes to 2 based numerals.  Few Examples 1. AND has properties of Multiplication. 2. OR has properties of Addition 3. Left shift is equal to Multiplication by 2 4. Right shift is equal to division by 2 SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Demo  Show bit program SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Hexadecimal Numbers.  Has 16 Digits 0-9 then A, B, C, D, E, F  No relation with computers.  Easy to map to binary numbers.  0xDEADBEAD is a hex decimal 32 bit number.  Conversion to binary is very easy as each just concatenate conversion of each digits.  So most of the display of binary numbers in computers are via hex decimal to save space and better readability. SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Example conversion to binary  0xDEADBEAD  0x1234ABCD SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Demo  In calc.exe conversion. SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

negative numbers  2’s compliment SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Demo of 2’s compliment SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Bit Fields struct myBits { bool first : 1; bool second : 1; bool third : 1; bool forth : 1; }; SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Demo  Bit Fields SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)

Thank you SourceLens.org Copyright. All rights reserved. Content Owner - Meera R (meera at sourcelens.org)