Binary Arithmetic

Clive Max Maxfield , in Bebop to the Boolean Boogie (Third Edition), 2009

Publisher Summary

Unsigned binary numbers don't have the concept of a sign (plus or minus), which means they can be used to represent just positive values. Each " 10 " character represents a single bit; the right-hand flake is known as the Least Meaning Fleck (LSB) because it represents the smallest value. Ii unsigned binary numbers may be added together using a procedure identical to that used for decimal addition. First, the two least significant $.25 are added together to give a sum and, possibly, a carry-out to the next stage. This process is repeated for the remaining $.25, progressing toward the about significant. In the instance of binary (base-2) numbers, the radix complement is known equally the twos' complement and the macerated radix complement is known as the ones' complement. Again, the standard way of performing the performance would be to decrease the subtrahend (00011110 2) from the minuend (00111001 2), which may require the apply of 1 or more borrow operations. In standard decimal arithmetic, numbers are typically represented in a form known as sign-magnitude, which means prefixing values with plus or minus signs (by default, numbers without signs are assumed to represent positive values). Signed binary numbers have the concept of a sign, and they tin be used to correspond both positive and negative values. The stop upshot of using signed binary numbers is to profoundly reduce the complexity of operations within a reckoner. Binary numbers may be multiplied together past means of a shift-and-add technique.

Read full chapter

URL:

https://www.sciencedirect.com/science/article/pii/B9781856175074000085

Pieces Parts

Darren Ashby , in Electrical Engineering 101 (Third Edition), 2012

Binary Numbers

Binary numbers are so basic to electrical applied science that I nearly omitted this department on the premise that you would already know about them. However, my own words, "drill the basics," kept haunting me. So if you already know this stuff forwards and backward, you are authorized to skip this section, just if those same words start to haunt y'all, as I hope they will, you should at least skim through it.

Binary numbers are simply a way to count with only two values, i and 0—convenient numbers for reasons nosotros will discuss later. Binary is also known every bit base 2. In that location are other bases, such as base of operations eight (octal) and base 16 (hexadecimal), that are ofttimes used in this field, but it is primarily for the reason that they represent binary numbers hands. The mutual base that everyone is used to is decimal, 22 besides known as base of operations 10. Think of it this way: The base of the counting system is the point at which you lot move a digit into the left column and start over at 0. For example, in base 10 yous count 0, one, ii, iii … vii, eight, ix and and so you chalk 1 up in the left column and start over at 0 for the number 10. In base viii you only get to 7 earlier yous have to start over: 0, 1, 2 … five, 6, 7, ten, 11, so on. Base of operations xvi starts over at 15 in the same fashion, but to adhere to the rule of one digit in the column earlier we ringlet over into the next digit, we employ letters to represent ten through 15. Table 3.1 shows an easy mode to meet this human relationship.

Tabular array 3.i. Decimal and Hexadecimal Numbers

Decimal, Base 10 Hexadecimal, Base 16
0 0
ane 1
two two
3 three
4 4
5 five
6 6
7 seven
viii eight
9 nine
10 A
11 B
12 C
13 D
14 E
15 F
16 10
17 11
So on …

Note again how the numbers offset over at the corresponding base. Y'all might also notice that I started at 0 in the counting procedure. 23 It should be stressed that 0 is an of import part of whatsoever counting organisation, a fact that I think tends to become overlooked. If yous think about it, when 0 is included, the point at which base 10 rolls over is the 10th digit and the point at which base 8 rolls over is the 8th digit. The same relationship exists for any base number y'all use.

So, let's get dorsum to binary or base two. The first time I saw binary numbers I thought, "Wow, what a tantalizing 24 numeric organisation; just as before long every bit you brand one move to get where you are going, it is time to starting time over again." The numbers go like this: 0, one, 10, 11, 100 …. Again, I think a table is in club—see Tabular array 3.2.

Table 3.2. Decimal, Binary, Octal, and Hexadecimal Number Comparison

Decimal Base ten Binary Base ii Octal Base 8 Hexadecimal Base 16
0 0 0 0
1 one 1 1
2 10 two two
iii 11 3 3
4 100 four iv
5 101 v 5
6 110 6 6
7 111 vii 7
eight 1000 ten viii
9 1001 11 9
10 1010 12 A
xi 1011 xiii B
12 1100 xiv C
13 1101 xv D
14 1110 16 E
fifteen 1111 17 F
16 10000 20 10
17 10001 21 11
18 10010 22 12
And so on …

Detect how base viii and base of operations sixteen curl over right at the aforementioned indicate that the binary numbers get an actress digit. That is why they are user-friendly to use in representing binary numbers. You might also have noticed that decimal numbers don't line upwards equally nicely.

Another pattern you lot should see in this table is that you striking twenty in base 8 at the same point at which you encounter 10 in base 16. This makes sense because 1 base is exactly double the other. Tin you extrapolate what base of operations iv might practise?

This leads to another trick with binary numbers. Each significant digit doubles the value of the previous one (just as every digit you add in decimal is worth x times the previous one). Allow's expect at yet another table—see Table 3.three.

Table 3.3. Doubling Digits

Decimal 128 64 32 xvi viii 4 2 ane
Binary 10000000 million 100000 10000 g 100 10 1

You tin add up the values of each digit where you have a 1 in binary to get the decimal equivalent. For example, have the binary number 101. There is a 1 in the 1s column and in the 4s column. Add 1 plus four and you lot get five, which is 101 in binary. You might also notice that the numbers yous tin can represent double for every digit you add to the number. For instance, four digits allow you count to 15, and eight digits volition get you to 255. (This causes some of us more than extroverted engineers to attempt to become the life of the party past showing their friends that they can count to 1023 with the fingers on their hands. These attempts ordinarily fail.)

All the math tricks you learned with decimal numbers utilise to binary as well, every bit long as you consider the base y'all are working in.

For example, when y'all multiply by ten in decimal, you simply put a 0 on the end, right? The same idea applies to binary, but the base of operations is 2, so to multiply by two, you but stick a 0 on the cease, shifting everything else to the left. When dividing by 10 in decimal you lot simply lop off the last digit and keep whatever was there every bit a remainder. Dividing past 2 in binary works the same way, shifting everything to the right, simply the residue is always 0 or 1—a fact that is user-friendly for math routines, as we will learn later.

For any reason, almost electronic components like to manage binary numbers in groups of four digits. This makes hexadecimal (or hex) numbers a type of shorthand for referring to binary numbers. It is a good autograph to know.

In the electronics world, each binary digit is commonly referred to every bit a bit. A group of eight $.25 is called a byte and four bits is called a crumb. So if you "byte" off more than you tin chew, perhaps you should effort a "nibble" next time.

Dorsum to the betoken: Since a hex number nicely represents a nibble, and there are ii nibbles in a byte, you will often run into two hex numbers used to draw a byte of binary information. For instance, 0101 1111 can exist described as 5 F or 1110 0001 as East i. In fact, you lot can hands determine this past looking upwardly the hex equivalent to any nibble using Table iii.2.

To sum things up, binary numbers are a style to count using only two symbols; they are commonly referred to using hex numbers as a type of shorthand notation. When logic circuits came along, the fact that they represented information with only ii symbols—on or off, loftier or depression—made them dovetail nicely with binary numbers and binary math.

Read total chapter

URL:

https://world wide web.sciencedirect.com/science/article/pii/B9780123860019000039

Binary Number System – Outputting Data

John Iovine , in Moving-picture show Projects for Not-Programmers, 2012

Publisher Summary

The binary number system is important because this is the number system more often than not used past microcontrollers, equally well as computers. The smallest element in the binary number system is a bit. The term binary provides a hint to the values independent in a bit. Binary means 2, equally in 0 or i, On–Off, Aye–No, True–False, etc.; i gets the idea. A bit may contain one of two values. This number system is as well called a Base two number system. The name flake is a wrinkle of the term Binary Digit. In computer lingo, a bit can accept i of ii values, 0 or 1. If dealing in a logic mode, the values are true and simulated where Truthful = 1 and False = 0.

Read full chapter

URL:

https://world wide web.sciencedirect.com/science/commodity/pii/B978185617603300004X

Digital Systems

W. Bolton , in Programmable Logic Controllers (Sixth Edition), 2015

3.5.1 Signed Numbers

The binary numbers considered and then far contain no indication as to whether they are negative or positive and are thus said to exist unsigned. Since in that location is more often than not a need to handle both positive and negative numbers, at that place needs to be some way of distinguishing betwixt them. This can exist done by adding a sign bit. When a number is said to be signed, its MSB is used to point the sign of the number; a 0 is used if the number is positive and a 1 is used if it is negative. Thus for an 8-bit number we have:

When we accept a positive number, we write it in the normal way, with a 0 preceding it. Thus a positive binary number of 10110 is written equally 010110. A negative number of 10110 is written as 110110. However, this is non the near useful way of writing negative numbers for ease of manipulation by computers.

Read full chapter

URL:

https://www.sciencedirect.com/scientific discipline/article/pii/B9780128029299000030

Digital Command Systems

EA Parr MSc, CEng, MIEE, MInstMC , in Electric Engineer's Reference Book (Sixteenth Edition), 2003

14.9.1 Digital to analog conversion (DAC)

A binary number can represent an analog voltage. An eight bit number, for example, represents a decimal number from 0 to 255 (or −128 to +127 if 2's complement representation is used). An 8 bit number could therefore represent a voltage from 0 to 2.55 V, say, with a resolution of 10 mV. A device which converted a digital number to an analog voltage is chosen a digital to analog converter, or DAC.

Common DAC circuits are shown on Figure 14.sixty , in each case the output voltage is related to the binary pattern on the switches. In exercise, FETs are used for the switches, and usually an IC DAC is used. The R-2R ladder circuit is particularly well suited to IC construction.

Figure fourteen.60. Digital to analog converters: (a) weighted resistors with OpAmp adder; (b) R-2R ladder

Read total chapter

URL:

https://www.sciencedirect.com/scientific discipline/article/pii/B9780750646376500149

Genetic Algorithms and Their Applications to Water Resource Systems

Deepti Rani , ... Muthiah Perumal , in Metaheuristics in H2o, Geotechnical and Send Engineering, 2013

Binary Coding

The about normally used representation of chromosomes in the GA is binary coding by using binary numbers 0 and 1. In this coding, each conclusion variable in the parameter gear up is encoded equally a binary string, and these are concatenated to form a chromosome. The length of the binary substring (i.east., number of bits) for a variable depends on the size of the search space and the number of decimal places required for accuracy of the decoded variable values (Michalewicz, 1999). If each decision variable is given a cord of length L, and in that location are n such variables, and so the chromosome volition have a total cord length of nL. For case, let there be ii determination variables, x i and x 2, and let the string length be 5 for each variable. And then the chromosome length is ten, as shown in Figure iii.2.

Effigy iii.2. Formation of chromosome.

The search space is divided into ii L intervals, each having a width equal to (x i,maxx i,min)/ii L for a binary string of length Fifty, where x i,max is the upper leap of the decision variable, and 10 i,min is the lower bound of the decision variable:

(iii.2) d = ( x i , max 10 i , min ) / two L defines the solution accuracy

The binary numbers have a base of ii and use only ii characters, 0 and 1. A binary string, therefore, is decoded using Eq. (3.3):

(3.3) N = a n 2 north + a n 1 2 due north i + + a ane ii i + a 0 2 0

where

a i is either 0 or ane (ith scrap in the string),

ii n represents the ability of ii of digit a i ,

n is the number of bits in binary-coded decision variable (i.e., Fifty−1),

North is the decoded integer value of the binary string,

and the corresponding actual value of the variables is obtained using Eq. (three.4):

(3.4) ten i = 10 i , min + ten i , max x i , min 2 L 1 N

For this example, let the search space for decision variables x 1 and x two range from 0 to five and 1 to 10, respectively. For the chromosome shown in Figure iii.2, the decoded value for the substrings and the respective value of the decision variables will be as shown in Tabular array iii.1.

Table 3.1. Coding and Decoding in GAs

Decision Variables
x one 10 2
Chromosomes represented as binary strings assuming string length, L=v 10001 01111
Decoded integer value one.24+0.two3+0.22+0.ii1+0.20=17 0.24+1.2three+one.twoii+1.ii1+1.two0=fifteen
Corresponding value of decision variable with solution accuracy (x maxx min)/(2 L −i) ii.74 4.84

Using string length L=5, the entire search space for decision variable 10 one can be divided into 31 intervals of 0.sixteen width each, every bit shown in Table 3.2. The solution accuracy may exist increased by increasing the length of the string. The lower and upper bounds of the existent-value search infinite (i.e., 0 and 5) can be mapped into binary numbers using Eq. (3.2), and all the other intermediate values (i.east., 0–31) tin can also exist easily expressed in binary numbers using Eq. (3.3). The entire search infinite for x 1 in binary encoding and decoded real values are given in Table iii.2. Different ranges and accuracies can be considered in GAs through different binary substring lengths for unlike decision variables. All GA operators are performed on binary strings and once GA optimization is completed, the binary strings can be decoded into real values.

Table 3.2. Binary and Real Value Search Infinite for Decision Variable x1

Binary encoding Decoded value Corresponding real value of 101 , in the search space
00000 0 0.00
00001 one 0.16
00010 two 0.32
00011 iii 0.48
00100 4 0.65
00101 5 0.81
00110 vi 0.97
00111 7 1.thirteen
01000 8 1.29
01001 9 ane.45
01010 x ane.61
01011 11 one.77
01100 12 1.94
01101 13 2.10
01110 14 2.26
01111 15 two.42
10000 sixteen 2.58
10001 17 2.74
10010 xviii 2.90
10011 19 three.06
10100 20 iii.23
10101 21 iii.39
10110 22 3.55
10111 23 three.71
11000 24 iii.87
11001 25 4.03
11010 26 4.19
11011 27 4.35
11100 28 4.52
11101 29 4.68
11110 30 four.84
11111 31 five.00

Read full chapter

URL:

https://www.sciencedirect.com/science/article/pii/B9780123982964000039

Constants

Marking Siegesmund , in Embedded C Programming, 2014

Signed Integers

The binary numbers shown above are unsigned numbers. An 8-fleck memory prison cell tin can have a number from 0 to 255. Information technology is sometimes helpful to correspond negative numbers in C. When doing then, ane binary position is used for the sign. 0 is positive and 1 is negative. The balance of the binary positions are in what is referred to as a 2'due south complement format . The 2'due south complement format has an arithmetic advantage over what might seem to exist a simpler scheme. A −two in 2's complement form at looks like this:

1 i 1 1 1 1 1 0

When adding i to this, the issue is:

1 1 one 1 i 1 1 1

And this is the 2'south complement representation for a −1. That is the preferred way it should work. Add ane to −2 and go −1. If adding another 1 (think of the odometer) the result is:

0 0 0 0 0 0 0 0

Just as any mathematician would expect.

Recollect of the odometer starting out at all 0s. If wanting to represent a −1, and so move information technology backwards 1 to consequence in all 1s.

In C, signed integers are represented like this:

x=−123;

Read total chapter

URL:

https://world wide web.sciencedirect.com/science/article/pii/B9780128013144000028

Arithmetics circuits

B. HOLDSWORTH BSc (Eng), MSc, FIEE , R.C. WOODS MA, DPhil , in Digital Logic Design (4th Edition), 2002

12.17 Multiplication

Multiplication of binary numbers can be achieved either combinationally or sequentially. The simplest form of binary multiplication is multiplication by the base 2. When multiplying by the base 10 in the decimal number system a shift to the left of one place occurs; for instance, ix × 10 = 90 and the nine has moved one identify to the left. Similarly, if a binary number such as 1101 is multiplied past the base 2 it becomes 11010, and if the number had been stored in a annals this would have represented a shift left of one identify in the annals. In this instance (1101) 2 = (13)x and (11010)2 = (26)10.

Read full chapter

URL:

https://www.sciencedirect.com/science/commodity/pii/B9780750645829500135

Microcomputer Systems

Dogan Ibrahim , in Designing Embedded Systems with 32-Bit PIC Microcontrollers and MikroC, 2014

1.9 Converting Binary Numbers into Hexadecimal

To convert a binary number into hexadecimal, arrange the number in groups of four and find the hexadecimal equivalent of each grouping. If the number cannot be divided exactly into groups of four, insert zeroes to the left-paw side of the number.

Example 1.vi

Catechumen binary number 100111112 into hexadecimal.

Solution 1.6

First, split the number into groups of four and and then detect the hexadecimal equivalent of each group:

          10011111=1001   1111

                        9       F

The required hexadecimal number is 9Fsixteen.

Example i.7

Convert binary number 1110111100001110 ii into hexadecimal.

Solution i.7

Kickoff, divide the number into groups of four then discover the equivalent of each group:

  1110111100001110=1110   1111   0000   1110

                          E       F       0       E

The required hexadecimal number is EF0Exvi.

Case one.viii

Convert binary number 111110 two into hexadecimal.

Solution 1.viii

Since the number cannot be divided exactly into groups of four, we have to insert zeroes to the left of the number:

  111110=0011   1110

            3         E

The required hexadecimal number is 3E16.

Table 1.two shows the hexadecimal equivalent of numbers 0–31.

Table i.two. Hexadecimal Equivalents of Decimal Numbers

Decimal Hexadecimal Decimal Hexadecimal
0 0 16 x
1 1 17 11
2 two xviii 12
three iii 19 thirteen
iv 4 20 fourteen
5 five 21 15
6 half dozen 22 16
vii 7 23 17
8 8 24 18
9 9 25 nineteen
10 A 26 1A
11 B 27 1B
12 C 28 1C
13 D 29 1D
14 Due east thirty 1E
15 F 31 1F

Read full chapter

URL:

https://world wide web.sciencedirect.com/scientific discipline/commodity/pii/B9780080977867000014

Dynamic Range

Morgan Jones , in Valve Amplifiers (Fourth Edition), 2012

Precision

Computers use binary numbers, so if nosotros make our numerical measurement more precise by using smaller quantising levels, at that place must be more of them, and a binary word comprising more than bits is required. CD used a 16-bit word, and because there are ii possible states for each bit, the total number of different levels that can be described by a sixteen  bit discussion is 216=65,536. Similarly, a 24   fleck system tin depict ii24=16,777,216 different levels, but requires one-and-a-one-half times as much retention to store each word (24/sixteen=1½).

Equally a dominion of thumb (ignoring dither), the Dynamic Range (DR) of a digital arrangement is:

DR dB = six n

where n=number of $.25.

Thus, a sixteen   bit system has a theoretical dynamic range of 6×sixteen=96   dB and a 24   flake system 144   dB (never achieved considering Counterpart to Digital Convertors (ADCs) simply aren't that good).

We could determine to exist more than precise by making more numerical measurements. Sampling twice as frequently doubles the retentivity required.

To sum up, a more precise clarification generates more data, requiring more memory, and this will get significant later.

Read full chapter

URL:

https://www.sciencedirect.com/science/article/pii/B9780080966403000034