Appendix b : hexadecimal and binary notation – KROHNE MFC 010 C Converter User Manual
Page 94
92
MFC010 Interface Manual
Appendix B : Hexadecimal and Binary Notation
The Binary ( Base 2 ) and Hexadecimal ( Base 16 ) mathematical notations are more commonly used in
computer systems because they can be used to more easily represent the digital values involved. Within
this document Binary numbers are indicated by a s ubscript “2” appended t he number, e.g. 10101
2
, and
Hexadecimal numbers are indicated by a subscript “16” appended to the number, e.g. E45F
16
.
Where decimal numbers are represented using the digits 0 to 9, binary numbers are represented using
the digits 0 to 1, and hexadecimal numbers are represented using the digits 0 to 9 and A to F. i.e.
Decimal
Binary
2
Hexadecimal
16
0
0000
0
1
0001
1
2
0010
2
3
0011
3
4
0100
4
5
0101
5
6
0110
6
7
0111
7
8
1000
8
9
1001
9
10
1010
A
11
1011
B
12
1100
C
13
1101
D
14
1110
E
15
1111
F
As with decimal numbers, the most significant, MS, digit of a Binary or Hexadecimal number is on the left
of the number and the least significant, LS, digit is on the right. e.g. for the decimal number 34567, the MS
digit is 3 and the LS Digit is 7.
The standard data representation within computer systems is the “Byte” which consists of 8 binary digits,
or “bits”. Each byte, being 8 bits long can easily be represented as two Hexadecimal digits.
e.g.
F F
16
Hexadecimal = 1111 1111
2
Binary = 255 Decimal
3 A
16
Hexadecimal = 0011 1010
2
Binary = 58 Decimal
The “Bits” of a byte are indexed from the LS bit, which is bit 0 up t o the MS bit which is bit 7. E ach bit
represents a value of 2
index
, such that bit 7 represents 2
7
= 128, and bit 3 represents 2
3
= 8 and so on. So
an 8 bit binary value of 00110010
2
is equal to a decimal value of 2
1
+ 2
4
+ 2
5
= 2 + 16 + 32 = 50. With all
of the bits of an 8 eight bit binary value set, the result will be 2
8
– 1 = 255 (2
0
+ 2
1
+ 2
2
+ 2
3
+ 2
4
+ 2
5
+ 2
6
+ 2
7
= 1 + 2 + 4 + 8 + 16 + 32 + 64 + 128 = 255).
When representing numbers within a c omputer system, multiple bytes are used to form values up to 16,
32 and 64 bits long. This allows the computer system to represent whole numbers up to 2
64
- 1. For the
representation of larger numbers and fractions, the computer system will use “Floating Point”
representations, see Appendix C for further details.
When t ransmitting and r eceiving dat a i n a s erial f ormat as w ith t he Modbus protocol it is important to
understand in which order the register values are transmitted. The Modbus registers are 16 bits long and
can therefore represent integer values up to 2
16
- 1 = 65535. The registers are transmitted as two bytes,
also known as characters, with the most significant byte being transmitted before the least significant
byte. T he l east s ignificant by te c ontains t he 8 l east s ignificant bi ts, i .e. bi ts 0 t o 7, w hile the most
significant by te c ontains t he 8 m ost s ignificant bi ts, i .e. bi ts 8 t o 15 i n a 16 bi t v alue. Each byte is
transmitted in order from its most significant bit down to its least significant bit.