Number Systems and Codes Chapter 3 Decimal Each place in the decimal system represents a power of ten Hundreds Tens Ones Tenths Hundredths Binary Each place in the binary system represents a power of two ID: 730449
Download Presentation The PPT/PDF document "Programming Logic Controllers" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Programming Logic Controllers
Number Systems and Codes
-
Chapter
3Slide2
Decimal
Each “place” in the decimal system represents a power of ten
Hundred’s
Ten’s
One’s
Tenths
Hundredth’s Slide3
Binary
Each “place” in the binary system represents a power of two
Four’s
Two’s
One’s
Half’s
Quarter’sSlide4
Hexadecimal
Each “place” in the hexadecimal system represents a power of sixteen
0 – 9 = 0 – 9
A = 10
B = 11
C = 12
D = 13
E = 14
F = 15Slide5
Hexadecimal and Binary
Hex numbers can be preceded with 0x
Hex is a shorthand way of writing binary.
Each Hex digit is 4 binary digits
So
h
ex 0x12 is binary
0001
0010
So hex 0xA
F
is binary
1010
1111Slide6
Octal
Each “place” in the octal system represents a power of eight
Each
octal digit
is
3
binary digitsUses digits 0-7Some systems indicateoctal numbers using a
leading 0
Eg
02
3
=
010
011
Eg 075 = 111101 Slide7
Programming Notes
Many programming environments allow you to specify literal constants in other than decimal formats. The following is one somewhat common syntax.
0x prefix indicates hexadecimal
0b prefixed indicate binary
0 prefix indicates octalSlide8
Binary Coded Decimal - BCD
4 bits represent a single decimal digit
Only 0 – 9 are valid
BCD
0111
0011
00010010 = decimal 73
1
2Slide9
Gray Code
Special encoding system where two successive numbers are one “bit flip” apart
00 = 0
01 = 1
11 = 2
10 = 3
Special uses like optical encodersSlide10
Binary Arithmetic
Addition
Subtraction
Multiplication
DivisionSlide11
Binary Fractions
Hole around zero
Decimal .1 has no binary equivalent
1/3 has no decimal equivalent (or binary)
1/2 + 1/4 + 1/8 + 1/16 + 1/32 + …