SlideShare a Scribd company logo
1 of 29
Computer and Network
Technology (CNT)
Chapter: Fundamentals
Lesson: Data Representation in Computers
Representation of Integers
Lecturer: Susantha Herath PGD in IT (MBCS), PGD in Marketing (Uni. Of Kln)
Lecture 02 bcsonlinelectures.com
Few basic things to know
 Most Significant Bit (MSB) also called as Most Significant Digit (MSD). This is
indeed the first digit (from left) in a binary number. More accurately the digit
with the highest radix (base) value.
 Least Significant Bit (LSB) or Least Significant Digit (LSD). This is the digit of a
binary number with the least radix value, probably the last digit.
 In binary number one digit is called as a bit.
 Computer memory is a place that store data and it has a fixed length of bits.
Generally 8bit, 16bit, 32bit and 64bit in length.
1001100100111
212 (MSD) 20 (LSD)
Data Representation
 Computer uses a fixed number of bits to represent a single piece of data. Generally
computers use 8bit, 16bit, 32bit and 64bit in size of binary numbers to represent
different type and size of data.
 N-number of bit memory (location) can store 2n of different types of values.
 For an example 8bit memory can store 256 of different data values.
 3bit memory can store 8 distinct values (patterns)
000, 001, 010, 011, 100, 101, 110, or 111
 When we interpret these values, we need to know exactly what represent with
these values.
 If we know that these represent decimal numbers, then we know it is from 0-7 then
it is a different value.
 So this interpretation of a binary pattern called data representation or encoding.
Integer Representation
 Integers are whole numbers or fixed point numbers. The radix point is fixed after
the LSB.
Example:
377410 is a fixed point number (integer)
2949.9410 is a floating point number (real number)
54533. 4573.55
LSB Radix Point Fixed
Radix Point Moved from LSB
Integer Representation
 In a computer integers and floating point numbers are treated differently and
processed separately. Floating point numbers are processed in a separate
processor called floating point processor.
 Computers use fixed number of bits to represent integers. Commonly use bit
lengths are 8bit, 16bit, 32bit and 64bit.
 There are two types of integers
 Unsigned integers: can represent zero and positive numbers only
 Signed integers: can represent zero, positive and negative numbers.
 There are three schemas (ways) to represent signed integers.
 Sign Magnitude representation
 1’s complement representation
 2’s complement representation
Integer Representation
 We learned about two different types of Integers;
 Unsigned Integers – that can represent only zero and positive numbers.
The value of an unsigned integer interpreted as the “magnitude of
underlying binary pattern or the normal way we convert binary to decimal.
Example: 8bit binary number 0100 0010B (B = Binary)
0100 0010B = 2x21 + 2x26 = 4+64 = 68D (D = Decimal)
8bit = 0000 0000
16bit = 0000 0000 0000 0000
32bit = 0000 0000 0000 0000 0000 0000 0000 0000
64bit = 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
All above numbers represent zero in different bit systems. The bit length of each system is different.
n-bit Unsigned Integers
 An n-bit pattern can represent 2n distinct integers. This range from 0 to (2n)-1
n-bit Minimum 2n – 1 Maximum
8bit 0 28 – 1 255
16bit 0 216 – 1 65,535
32bit 0 232 – 1 4,294,967,295
64bit 0 264 – 1 18,446,744,073,709,551,615
When you are programming you need to select the correct and appropriate
bit size to store integers. If you want to store small numbers less than 255,
you can select 8bit number, selecting 32bit length to store small numbers is a
waste of resources.
Signed Integers
 Signed integers can represent zero, positive and negative numbers.
 The MSB (Most Significant Bit) – Normally the first bit from left, represent the
sign of the integer. Zero (0) to represent positive (+) sign and One (1) to
represent negative (-) sign.
 The magnitude of the integer represent differently in different schemas.
 There are three schemas to represent signed integers.
1. Sign Magnitude Representation
2. 1’s Complement Representation
3. 2’s Complement Representation
Example of Signed Integers:
+2344 is a positive integer -23434 is a negative integer
n-bit Sign Magnitude Representation
 Most Significant Bit (MSB) is the sign bit. 0 representing positive and 1
representing negative signs.
 The remaining (n-1) bits represent the magnitude / absolute value of the
integer interpreted according to its binary pattern.
Examples:
n=8 (8bit number) and binary number is 01000001
Sign bit (MSB) is 0  this is a positive number
Absolute value 1000001  65
01000001B = +65D
B = Binary, D = Decimal
n-bit Sign Magnitude Representation
Examples:
n=8 (8bit number) and binary number is 00000000
Sign bit (MSB) is 0  this is a positive number
Absolute value 0000000  0
00000000B = +0D
n=8 (8bit number) and binary number is 10000000
Sign bit (MSB) is 1  this is a negative number
Absolute value 0000000  0
10000000B = -0D
n-bit Sign Magnitude Representation
Problems (Drawbacks / Limitations) of Sign Magnitude Representation:
 There are two
representation for the
number zero
 Even the number zero
need to have a sign, since
it is not necessary nor
accurate and may leads to
confusions.
 Positive and negative
numbers need to process
separately.
n-bit 1’s Complement Representation
In this representation, the MSB is the sign bit 0 represent positive and 1
represent negative numbers. The remaining n-1 bits represent the magnitude
(value) of the integer.
 In positive integers, the value of the integer is the binary pattern (value) of
the n-1 bit magnitude. Same as Sign Magnitude Representation.
 For negative integers, the absolute value is the n-1 binary pattern value of
the inverse magnitude (complement).
Example: 1 000 0001B (sign bit = 1, negative integer)
Complement of 000 0001 is 111 1110 = 126D
1 000 0001B = -126D
n-bit 1’s Complement Representation
In the 1’s Complement
Representation, there are two
different representation for zero;
0000 0000B and 1111 1111B
hence +0 and -0
Since the processing method of
positive and negative integers
are different, computer need to
process the positive and
negative numbers separately.
n-bit 2’s Complement Representation
In 2’s Complement Representation also the MSB is the sign bit 0 represent
positive and 1 represent negative integers.
For positive integers, the value of the integer equal to the magnitude of n-1
binary pattern
For negative integers, the absolute value of the integer equal to the magnitude
of the complement of n-1 binary pattern plus one.
Example: 1 000 0001B (MSB = 1 is a negative number)
Complement of 000 0001 = 111 1110
Let’s add 1 to the complement = 111 1111 = 127
1 000 0001B = -127D
n-bit 2’s Complement Representation
Advantages of 2’s Complement
Representation
 There is only one
representation for the number 0
 In binary addition and
subtraction, both positive and
negative numbers can treated
together (process together)
 Subtraction can use the addition
logic
 Computers use 2’s Complement
Representation for processing
integers.
n-bit 2’s Complement Representation
Addition, Subtraction, Overflow and Underflow
Addition of positive integers
Example: n=8, 65D + 5D = 70D
65D  0100 0001B
5D  0000 0101B
65D + 5D  0100 0110B OK 70D within the range of -128 to +127
Subtraction is the addition of positive and negative integers
Example: n=8, 65D – 5D = 60D  65D + (-5D)
65D  0100 0001B
-5D  1111 1011B
65D + (-5D)  0011 1100B  60D OK within the range of -128 to +127
n-bit 2’s Complement Representation
Addition, Subtraction, Overflow and Underflow
Overflow and underflow happens when the result is not within the acceptable range
Example of Overflow: n=8, 127D + D = 129D (not within -128 and +127, exceed
maximum value)
127D  0111 1111B
2D  0000 0010B
127D + 2D  1000 0001B  -127D wrong answer
Example of underflow: n=8, -125D – 5D = -130D (not within -128 and +127, below
the minimum value)
-125D  1000 0011B
-5D  1111 1011B
-125D + (-5D)  0111 1110B  +126D wrong answer
n-bit 2’s Complement Representation
Range of n-bit 2’s complement signed integers
An n-bit 2’s complement integer can represent integers from -2(n-1) to +2(n-1)-1. This
can represent all the integers within the range without missing any intergers.
8bit from -128 to +127
16bit from -32,768 to +32,767
32bit from -2,147,483,648 to + 2,147,483,647
64bit from -9,223,372,036,854,775,888 to + 9,223,372,036,854,775,887
n-bit 2’s Complement Representation
decoding 2’s complement numbers
• Check the sign bit first. If sign bit = 0, the number is positive and the absolute
value if the binary value of remaining n-1 integers.
• If the sign bit = 1, the integer is negative. To get the absolute value;
• Invert remaining n-1 bits and add 1 or
• Scan from left until the first occurrence of 1. Flip all values from that point to
the left. Binary value of this pattern gives the absolute value of the negative
integer.
Example:
N=8 bit pattern = 1 100 0100 B
Negative number
Scan from right, until the first occurrence of 1, flip all values from that point to left
011 1100 B = 60 D
Represented negative value is -60 D
Big Endian vs. Little Endian
Modern computers store one byte of memory in single memory location / address.
1 byte = 8 bits. Therefore in 32bit integer stores in 4 memory locations.
Term “Endian” means the order of storing bytes in memory. In Big Endian standard
– the most significant byte stores first in the lowest memory location. In Little
Endian standard, the least significant byte (LSB) stores in the lowest memory
location.
Floating Point Number
Representation
A floating point number (also called as a real number) is a number with a decimal
point. A floating point number can represent a very large positive or negative
number as well as a very small negative or positive number. A real number has a
range of -1.23x1088 to 1.25x1088 including zero.
Scientifically a floating point number represent as a number with a fraction and
exponent of a certain radix. F x rE
Floating Point Number
Representation
Same floating point number can represent in different ways. Consider 5.456D
We can represent this number in following ways:
54.532 x 100
5.4532 x 101
0.54532 x 102 and so on….
Since there are many ways to represent the same floating point number, we need
to define a standard, so every floating point number should be in this standard. To
make it standard, we can normalized the fraction part. In normalized form, there is
only single none zero digit represent before the radix point. In above example
5.4532 x 101 is the normalized form of 54.532 number.
Floating Point Number
Representation
In computers, there is an issue of “Loss of Precision” in storing floating point
numbers. An n-bit system can only stores 2n distinct finite numbers. Even within a
small range 0.00 – 0.01, there are infinite number of decimal numbers. But the
number of bits in a computer system is limited, only a the approximate number
used, resulting in loss of accuracy.
Processing of a real number (floating number arithmetic) is very much less efficient
and slower than processing of integers. In computers, real numbers uses fraction
(F) and exponent (E) with radix (r) of 2. Both F and E can be negative or positive.
In modern computing uses IEEE 754 standard to represent floating point numbers.
There are two representation schemes
32 bit single precision and
64 bit double precision
IEEE-754 32-bit Single-Precision
Floating-Point Numbers
In 32-bit single precision floating point number representation, decimal number
represent in following structure:
• The most significant bit is the sign bit. Zero for positive numbers and One for
negative numbers.
• Next following 8bit represent the exponent (E)
• Remaining 23bit represent the fraction (F)
You may wonder why radix (r) is not represent here. Because radix is always 2 for
binary numbers (in computers).
IEEE-754 64-bit Double-Precision
Floating-Point Numbers
64-bit double precision floating point number representation is similar to 32-bit
single precision floating point number representation. Only difference is assignment
of bit range for exponent and fraction.
• The most significant bit is the sign bit. Zero for positive numbers and One for
negative numbers.
• Next following 11-bit represent the exponent (E)
• Remaining 52-bit represent the fraction (F)
Character Encoding
In computer memory, characters are represented (encode) using character
schemes called as “character set”, “charset”, “character map” or “code page”.
There are several standard schemes such as ASCII, EBCDIC, UTF, etc.
7-bit ASCII Code (aka US-ASCII, ISO/IEC 646, ITU-T T.50)
• ASCII (American Standard Code for Information Interchange) is one of the earlier
character coding schemes.
• ASCII is originally a 7-bit code. It has been extended to 8-bit to better utilize the 8-bit
computer memory organization. (The 8th-bit was originally used for parity check in
the early computers). This is called ASCII-8 Code.
EBCDIC Code
This is stands for “Extended Binary Code Decimal Interchange Code”. This is a 8-bit
code scheme without parity. With this up to 256 characters can be coded.
Character Encoding
Unicode (aka ISO/IEC 10646 Universal Character Set)
• Before Unicode, no single character encoding scheme could represent characters in
all languages.
• Unicode aims to provide a standard character encoding scheme, which is universal,
efficient, uniform and unambiguous. Unicode standard is maintained by a non-profit
organization called the Unicode Consortium (@ www.unicode.org). Unicode is an
ISO/IEC standard 10646.
• Unicode is backward compatible with the 7-bit US-ASCII and 8-bit Latin-1 (ISO-8859-
1). That is, the first 128 characters are the same as US-ASCII; and the first 256
characters are the same as Latin-1.
• Unicode originally uses 16 bits , which can represent up to 65,536 characters.
Summary
Inside the computer memory – integer 1, floating point 1.0, character 1 and string 1
are totally different. To write good and high performance programs, you need to
know these differences and use correct data type to store data in memory and later
on in databases as well.
• In 8-bit signed integer, integer number 1 is represented as 00000001B.
• In 8-bit unsigned integer, integer number 1 is represented as 00000001B.
• In 16-bit signed integer, integer number 1 is represented as 00000000 00000001B.
• In 32-bit signed integer, integer number 1 is represented
as 00000000 00000000 00000000 00000001B.
• In 32-bit floating-point representation, number 1.0 is represented as 0 01111111
0000000 00000000 00000000B, i.e., S=0, E=127, F=0.
• In 64-bit floating-point representation, number 1.0 is represented as 0 01111111111 0000
00000000 00000000 00000000 00000000 00000000 00000000B,
i.e., S=0, E=1023, F=0.
End of Lesson
www.bcsonlinelectures.com

More Related Content

What's hot

Introduction to binary number system
Introduction to binary number systemIntroduction to binary number system
Introduction to binary number systemVikas Dongre
 
Bucket sort- A Noncomparision Algorithm
Bucket sort- A Noncomparision AlgorithmBucket sort- A Noncomparision Algorithm
Bucket sort- A Noncomparision AlgorithmKrupali Mistry
 
1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx
1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx
1. Arithmetic Operations - Addition and subtraction of signed numbers.pptxJEEVANANTHAMG6
 
BCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codesBCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codesstudent
 
Kmap..(karnaugh map)
Kmap..(karnaugh map)Kmap..(karnaugh map)
Kmap..(karnaugh map)Zain Jafri
 
Number system.pdf
Number system.pdfNumber system.pdf
Number system.pdfDeepuGuna
 
Binaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemesBinaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemesDr. Anita Goel
 
Fixed point and floating-point numbers
Fixed point and  floating-point numbersFixed point and  floating-point numbers
Fixed point and floating-point numbersMOHAN MOHAN
 
Half adder & full adder
Half adder & full adderHalf adder & full adder
Half adder & full adderGaditek
 

What's hot (20)

Introduction to binary number system
Introduction to binary number systemIntroduction to binary number system
Introduction to binary number system
 
Bucket sort- A Noncomparision Algorithm
Bucket sort- A Noncomparision AlgorithmBucket sort- A Noncomparision Algorithm
Bucket sort- A Noncomparision Algorithm
 
Binary codes
Binary codesBinary codes
Binary codes
 
1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx
1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx
1. Arithmetic Operations - Addition and subtraction of signed numbers.pptx
 
Number System
Number SystemNumber System
Number System
 
BCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codesBCD,GRAY and EXCESS 3 codes
BCD,GRAY and EXCESS 3 codes
 
Binary arithmetic
Binary arithmeticBinary arithmetic
Binary arithmetic
 
Multiplexers & Demultiplexers
Multiplexers & DemultiplexersMultiplexers & Demultiplexers
Multiplexers & Demultiplexers
 
Signed Binary Numbers
Signed Binary NumbersSigned Binary Numbers
Signed Binary Numbers
 
Kmap..(karnaugh map)
Kmap..(karnaugh map)Kmap..(karnaugh map)
Kmap..(karnaugh map)
 
Number System
Number SystemNumber System
Number System
 
Number system.pdf
Number system.pdfNumber system.pdf
Number system.pdf
 
Chapter 1: Binary System
 Chapter 1: Binary System Chapter 1: Binary System
Chapter 1: Binary System
 
Binaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemesBinaty Arithmetic and Binary coding schemes
Binaty Arithmetic and Binary coding schemes
 
Fixed point and floating-point numbers
Fixed point and  floating-point numbersFixed point and  floating-point numbers
Fixed point and floating-point numbers
 
Two’s complement
Two’s complementTwo’s complement
Two’s complement
 
Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
 
Number system
Number systemNumber system
Number system
 
K - Map
  K - Map    K - Map
K - Map
 
Half adder & full adder
Half adder & full adderHalf adder & full adder
Half adder & full adder
 

Similar to Representation of Integers

chapter one && two.pdf
chapter one && two.pdfchapter one && two.pdf
chapter one && two.pdfmiftah88
 
CS304PC:Computer Organization and Architecture Unit- III PDF notes .pdf
CS304PC:Computer Organization and Architecture Unit- III PDF notes .pdfCS304PC:Computer Organization and Architecture Unit- III PDF notes .pdf
CS304PC:Computer Organization and Architecture Unit- III PDF notes .pdfAsst.prof M.Gokilavani
 
Lec 02 data representation part 1
Lec 02 data representation part 1Lec 02 data representation part 1
Lec 02 data representation part 1Abdul Khan
 
3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.pptRavikumarR77
 
Introduction of number system
Introduction of number systemIntroduction of number system
Introduction of number systemAswiniT3
 
Data Reprersentation
Data Reprersentation  Data Reprersentation
Data Reprersentation Kamal Acharya
 
Digital electronics & microprocessor Batu- s y computer engineering- arvind p...
Digital electronics & microprocessor Batu- s y computer engineering- arvind p...Digital electronics & microprocessor Batu- s y computer engineering- arvind p...
Digital electronics & microprocessor Batu- s y computer engineering- arvind p...ARVIND PANDE
 
Number system and codes
Number system and codesNumber system and codes
Number system and codesAbhiraj Bohra
 
CDS Fundamentals of digital communication system UNIT 1 AND 2.pdf
CDS Fundamentals of digital communication system UNIT 1 AND 2.pdfCDS Fundamentals of digital communication system UNIT 1 AND 2.pdf
CDS Fundamentals of digital communication system UNIT 1 AND 2.pdfshubhangisonawane6
 
Introduction to number system
Introduction to number systemIntroduction to number system
Introduction to number systemAswiniT3
 
Unit 1 data representation and computer arithmetic
Unit 1  data representation and computer arithmeticUnit 1  data representation and computer arithmetic
Unit 1 data representation and computer arithmeticAmrutaMehata
 
data representation
 data representation data representation
data representationHaroon_007
 
Lesson 1 basic theory of information
Lesson 1   basic theory of informationLesson 1   basic theory of information
Lesson 1 basic theory of informationRoma Kimberly Erolin
 
Lesson 1 basic theory of information
Lesson 1   basic theory of informationLesson 1   basic theory of information
Lesson 1 basic theory of informationRoma Kimberly Erolin
 

Similar to Representation of Integers (20)

chapter one && two.pdf
chapter one && two.pdfchapter one && two.pdf
chapter one && two.pdf
 
CS304PC:Computer Organization and Architecture Unit- III PDF notes .pdf
CS304PC:Computer Organization and Architecture Unit- III PDF notes .pdfCS304PC:Computer Organization and Architecture Unit- III PDF notes .pdf
CS304PC:Computer Organization and Architecture Unit- III PDF notes .pdf
 
Data Representation
Data RepresentationData Representation
Data Representation
 
Digital electronics
Digital electronicsDigital electronics
Digital electronics
 
Data Representation
Data RepresentationData Representation
Data Representation
 
Unit 2 Arithmetic
Unit 2 ArithmeticUnit 2 Arithmetic
Unit 2 Arithmetic
 
Lec 02 data representation part 1
Lec 02 data representation part 1Lec 02 data representation part 1
Lec 02 data representation part 1
 
3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt3.Fixed-Floating Point.ppt
3.Fixed-Floating Point.ppt
 
Introduction of number system
Introduction of number systemIntroduction of number system
Introduction of number system
 
Data Reprersentation
Data Reprersentation  Data Reprersentation
Data Reprersentation
 
Digital electronics & microprocessor Batu- s y computer engineering- arvind p...
Digital electronics & microprocessor Batu- s y computer engineering- arvind p...Digital electronics & microprocessor Batu- s y computer engineering- arvind p...
Digital electronics & microprocessor Batu- s y computer engineering- arvind p...
 
Number system and codes
Number system and codesNumber system and codes
Number system and codes
 
CDS Fundamentals of digital communication system UNIT 1 AND 2.pdf
CDS Fundamentals of digital communication system UNIT 1 AND 2.pdfCDS Fundamentals of digital communication system UNIT 1 AND 2.pdf
CDS Fundamentals of digital communication system UNIT 1 AND 2.pdf
 
Introduction to number system
Introduction to number systemIntroduction to number system
Introduction to number system
 
Unit 1 data representation and computer arithmetic
Unit 1  data representation and computer arithmeticUnit 1  data representation and computer arithmetic
Unit 1 data representation and computer arithmetic
 
data representation
 data representation data representation
data representation
 
Csc 2313 (lecture 3)
Csc 2313 (lecture 3)Csc 2313 (lecture 3)
Csc 2313 (lecture 3)
 
Csc 2313 (lecture 3)
Csc 2313 (lecture 3)Csc 2313 (lecture 3)
Csc 2313 (lecture 3)
 
Lesson 1 basic theory of information
Lesson 1   basic theory of informationLesson 1   basic theory of information
Lesson 1 basic theory of information
 
Lesson 1 basic theory of information
Lesson 1   basic theory of informationLesson 1   basic theory of information
Lesson 1 basic theory of information
 

Recently uploaded

internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 

Recently uploaded (20)

internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 

Representation of Integers

  • 1. Computer and Network Technology (CNT) Chapter: Fundamentals Lesson: Data Representation in Computers Representation of Integers Lecturer: Susantha Herath PGD in IT (MBCS), PGD in Marketing (Uni. Of Kln) Lecture 02 bcsonlinelectures.com
  • 2. Few basic things to know  Most Significant Bit (MSB) also called as Most Significant Digit (MSD). This is indeed the first digit (from left) in a binary number. More accurately the digit with the highest radix (base) value.  Least Significant Bit (LSB) or Least Significant Digit (LSD). This is the digit of a binary number with the least radix value, probably the last digit.  In binary number one digit is called as a bit.  Computer memory is a place that store data and it has a fixed length of bits. Generally 8bit, 16bit, 32bit and 64bit in length. 1001100100111 212 (MSD) 20 (LSD)
  • 3. Data Representation  Computer uses a fixed number of bits to represent a single piece of data. Generally computers use 8bit, 16bit, 32bit and 64bit in size of binary numbers to represent different type and size of data.  N-number of bit memory (location) can store 2n of different types of values.  For an example 8bit memory can store 256 of different data values.  3bit memory can store 8 distinct values (patterns) 000, 001, 010, 011, 100, 101, 110, or 111  When we interpret these values, we need to know exactly what represent with these values.  If we know that these represent decimal numbers, then we know it is from 0-7 then it is a different value.  So this interpretation of a binary pattern called data representation or encoding.
  • 4. Integer Representation  Integers are whole numbers or fixed point numbers. The radix point is fixed after the LSB. Example: 377410 is a fixed point number (integer) 2949.9410 is a floating point number (real number) 54533. 4573.55 LSB Radix Point Fixed Radix Point Moved from LSB
  • 5. Integer Representation  In a computer integers and floating point numbers are treated differently and processed separately. Floating point numbers are processed in a separate processor called floating point processor.  Computers use fixed number of bits to represent integers. Commonly use bit lengths are 8bit, 16bit, 32bit and 64bit.  There are two types of integers  Unsigned integers: can represent zero and positive numbers only  Signed integers: can represent zero, positive and negative numbers.  There are three schemas (ways) to represent signed integers.  Sign Magnitude representation  1’s complement representation  2’s complement representation
  • 6. Integer Representation  We learned about two different types of Integers;  Unsigned Integers – that can represent only zero and positive numbers. The value of an unsigned integer interpreted as the “magnitude of underlying binary pattern or the normal way we convert binary to decimal. Example: 8bit binary number 0100 0010B (B = Binary) 0100 0010B = 2x21 + 2x26 = 4+64 = 68D (D = Decimal) 8bit = 0000 0000 16bit = 0000 0000 0000 0000 32bit = 0000 0000 0000 0000 0000 0000 0000 0000 64bit = 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 All above numbers represent zero in different bit systems. The bit length of each system is different.
  • 7. n-bit Unsigned Integers  An n-bit pattern can represent 2n distinct integers. This range from 0 to (2n)-1 n-bit Minimum 2n – 1 Maximum 8bit 0 28 – 1 255 16bit 0 216 – 1 65,535 32bit 0 232 – 1 4,294,967,295 64bit 0 264 – 1 18,446,744,073,709,551,615 When you are programming you need to select the correct and appropriate bit size to store integers. If you want to store small numbers less than 255, you can select 8bit number, selecting 32bit length to store small numbers is a waste of resources.
  • 8. Signed Integers  Signed integers can represent zero, positive and negative numbers.  The MSB (Most Significant Bit) – Normally the first bit from left, represent the sign of the integer. Zero (0) to represent positive (+) sign and One (1) to represent negative (-) sign.  The magnitude of the integer represent differently in different schemas.  There are three schemas to represent signed integers. 1. Sign Magnitude Representation 2. 1’s Complement Representation 3. 2’s Complement Representation Example of Signed Integers: +2344 is a positive integer -23434 is a negative integer
  • 9. n-bit Sign Magnitude Representation  Most Significant Bit (MSB) is the sign bit. 0 representing positive and 1 representing negative signs.  The remaining (n-1) bits represent the magnitude / absolute value of the integer interpreted according to its binary pattern. Examples: n=8 (8bit number) and binary number is 01000001 Sign bit (MSB) is 0  this is a positive number Absolute value 1000001  65 01000001B = +65D B = Binary, D = Decimal
  • 10. n-bit Sign Magnitude Representation Examples: n=8 (8bit number) and binary number is 00000000 Sign bit (MSB) is 0  this is a positive number Absolute value 0000000  0 00000000B = +0D n=8 (8bit number) and binary number is 10000000 Sign bit (MSB) is 1  this is a negative number Absolute value 0000000  0 10000000B = -0D
  • 11. n-bit Sign Magnitude Representation Problems (Drawbacks / Limitations) of Sign Magnitude Representation:  There are two representation for the number zero  Even the number zero need to have a sign, since it is not necessary nor accurate and may leads to confusions.  Positive and negative numbers need to process separately.
  • 12. n-bit 1’s Complement Representation In this representation, the MSB is the sign bit 0 represent positive and 1 represent negative numbers. The remaining n-1 bits represent the magnitude (value) of the integer.  In positive integers, the value of the integer is the binary pattern (value) of the n-1 bit magnitude. Same as Sign Magnitude Representation.  For negative integers, the absolute value is the n-1 binary pattern value of the inverse magnitude (complement). Example: 1 000 0001B (sign bit = 1, negative integer) Complement of 000 0001 is 111 1110 = 126D 1 000 0001B = -126D
  • 13. n-bit 1’s Complement Representation In the 1’s Complement Representation, there are two different representation for zero; 0000 0000B and 1111 1111B hence +0 and -0 Since the processing method of positive and negative integers are different, computer need to process the positive and negative numbers separately.
  • 14. n-bit 2’s Complement Representation In 2’s Complement Representation also the MSB is the sign bit 0 represent positive and 1 represent negative integers. For positive integers, the value of the integer equal to the magnitude of n-1 binary pattern For negative integers, the absolute value of the integer equal to the magnitude of the complement of n-1 binary pattern plus one. Example: 1 000 0001B (MSB = 1 is a negative number) Complement of 000 0001 = 111 1110 Let’s add 1 to the complement = 111 1111 = 127 1 000 0001B = -127D
  • 15. n-bit 2’s Complement Representation Advantages of 2’s Complement Representation  There is only one representation for the number 0  In binary addition and subtraction, both positive and negative numbers can treated together (process together)  Subtraction can use the addition logic  Computers use 2’s Complement Representation for processing integers.
  • 16. n-bit 2’s Complement Representation Addition, Subtraction, Overflow and Underflow Addition of positive integers Example: n=8, 65D + 5D = 70D 65D  0100 0001B 5D  0000 0101B 65D + 5D  0100 0110B OK 70D within the range of -128 to +127 Subtraction is the addition of positive and negative integers Example: n=8, 65D – 5D = 60D  65D + (-5D) 65D  0100 0001B -5D  1111 1011B 65D + (-5D)  0011 1100B  60D OK within the range of -128 to +127
  • 17. n-bit 2’s Complement Representation Addition, Subtraction, Overflow and Underflow Overflow and underflow happens when the result is not within the acceptable range Example of Overflow: n=8, 127D + D = 129D (not within -128 and +127, exceed maximum value) 127D  0111 1111B 2D  0000 0010B 127D + 2D  1000 0001B  -127D wrong answer Example of underflow: n=8, -125D – 5D = -130D (not within -128 and +127, below the minimum value) -125D  1000 0011B -5D  1111 1011B -125D + (-5D)  0111 1110B  +126D wrong answer
  • 18. n-bit 2’s Complement Representation Range of n-bit 2’s complement signed integers An n-bit 2’s complement integer can represent integers from -2(n-1) to +2(n-1)-1. This can represent all the integers within the range without missing any intergers. 8bit from -128 to +127 16bit from -32,768 to +32,767 32bit from -2,147,483,648 to + 2,147,483,647 64bit from -9,223,372,036,854,775,888 to + 9,223,372,036,854,775,887
  • 19. n-bit 2’s Complement Representation decoding 2’s complement numbers • Check the sign bit first. If sign bit = 0, the number is positive and the absolute value if the binary value of remaining n-1 integers. • If the sign bit = 1, the integer is negative. To get the absolute value; • Invert remaining n-1 bits and add 1 or • Scan from left until the first occurrence of 1. Flip all values from that point to the left. Binary value of this pattern gives the absolute value of the negative integer. Example: N=8 bit pattern = 1 100 0100 B Negative number Scan from right, until the first occurrence of 1, flip all values from that point to left 011 1100 B = 60 D Represented negative value is -60 D
  • 20. Big Endian vs. Little Endian Modern computers store one byte of memory in single memory location / address. 1 byte = 8 bits. Therefore in 32bit integer stores in 4 memory locations. Term “Endian” means the order of storing bytes in memory. In Big Endian standard – the most significant byte stores first in the lowest memory location. In Little Endian standard, the least significant byte (LSB) stores in the lowest memory location.
  • 21. Floating Point Number Representation A floating point number (also called as a real number) is a number with a decimal point. A floating point number can represent a very large positive or negative number as well as a very small negative or positive number. A real number has a range of -1.23x1088 to 1.25x1088 including zero. Scientifically a floating point number represent as a number with a fraction and exponent of a certain radix. F x rE
  • 22. Floating Point Number Representation Same floating point number can represent in different ways. Consider 5.456D We can represent this number in following ways: 54.532 x 100 5.4532 x 101 0.54532 x 102 and so on…. Since there are many ways to represent the same floating point number, we need to define a standard, so every floating point number should be in this standard. To make it standard, we can normalized the fraction part. In normalized form, there is only single none zero digit represent before the radix point. In above example 5.4532 x 101 is the normalized form of 54.532 number.
  • 23. Floating Point Number Representation In computers, there is an issue of “Loss of Precision” in storing floating point numbers. An n-bit system can only stores 2n distinct finite numbers. Even within a small range 0.00 – 0.01, there are infinite number of decimal numbers. But the number of bits in a computer system is limited, only a the approximate number used, resulting in loss of accuracy. Processing of a real number (floating number arithmetic) is very much less efficient and slower than processing of integers. In computers, real numbers uses fraction (F) and exponent (E) with radix (r) of 2. Both F and E can be negative or positive. In modern computing uses IEEE 754 standard to represent floating point numbers. There are two representation schemes 32 bit single precision and 64 bit double precision
  • 24. IEEE-754 32-bit Single-Precision Floating-Point Numbers In 32-bit single precision floating point number representation, decimal number represent in following structure: • The most significant bit is the sign bit. Zero for positive numbers and One for negative numbers. • Next following 8bit represent the exponent (E) • Remaining 23bit represent the fraction (F) You may wonder why radix (r) is not represent here. Because radix is always 2 for binary numbers (in computers).
  • 25. IEEE-754 64-bit Double-Precision Floating-Point Numbers 64-bit double precision floating point number representation is similar to 32-bit single precision floating point number representation. Only difference is assignment of bit range for exponent and fraction. • The most significant bit is the sign bit. Zero for positive numbers and One for negative numbers. • Next following 11-bit represent the exponent (E) • Remaining 52-bit represent the fraction (F)
  • 26. Character Encoding In computer memory, characters are represented (encode) using character schemes called as “character set”, “charset”, “character map” or “code page”. There are several standard schemes such as ASCII, EBCDIC, UTF, etc. 7-bit ASCII Code (aka US-ASCII, ISO/IEC 646, ITU-T T.50) • ASCII (American Standard Code for Information Interchange) is one of the earlier character coding schemes. • ASCII is originally a 7-bit code. It has been extended to 8-bit to better utilize the 8-bit computer memory organization. (The 8th-bit was originally used for parity check in the early computers). This is called ASCII-8 Code. EBCDIC Code This is stands for “Extended Binary Code Decimal Interchange Code”. This is a 8-bit code scheme without parity. With this up to 256 characters can be coded.
  • 27. Character Encoding Unicode (aka ISO/IEC 10646 Universal Character Set) • Before Unicode, no single character encoding scheme could represent characters in all languages. • Unicode aims to provide a standard character encoding scheme, which is universal, efficient, uniform and unambiguous. Unicode standard is maintained by a non-profit organization called the Unicode Consortium (@ www.unicode.org). Unicode is an ISO/IEC standard 10646. • Unicode is backward compatible with the 7-bit US-ASCII and 8-bit Latin-1 (ISO-8859- 1). That is, the first 128 characters are the same as US-ASCII; and the first 256 characters are the same as Latin-1. • Unicode originally uses 16 bits , which can represent up to 65,536 characters.
  • 28. Summary Inside the computer memory – integer 1, floating point 1.0, character 1 and string 1 are totally different. To write good and high performance programs, you need to know these differences and use correct data type to store data in memory and later on in databases as well. • In 8-bit signed integer, integer number 1 is represented as 00000001B. • In 8-bit unsigned integer, integer number 1 is represented as 00000001B. • In 16-bit signed integer, integer number 1 is represented as 00000000 00000001B. • In 32-bit signed integer, integer number 1 is represented as 00000000 00000000 00000000 00000001B. • In 32-bit floating-point representation, number 1.0 is represented as 0 01111111 0000000 00000000 00000000B, i.e., S=0, E=127, F=0. • In 64-bit floating-point representation, number 1.0 is represented as 0 01111111111 0000 00000000 00000000 00000000 00000000 00000000 00000000B, i.e., S=0, E=1023, F=0.