Quantcast
Channel: Articles About Binary Numbers As They Exist Outside of Computers - Exploring Binary
Viewing all articles
Browse latest Browse all 17

Converting a Bicimal to a Fraction (Subtraction Method)

$
0
0

In my article “Binary Division” I showed how binary long division converts a fraction to a repeating bicimal. In this article, I’ll show you a well-known procedure — what I call the subtraction method — to do the reverse: convert a repeating bicimal to a fraction.

Equivalent Representations of 47/12, in Binary

Equivalent Representations of 47/12, in Binary

Bicimals

A bicimal is the base-two analog of a decimal; it has a bicimal point and bicimal places, and can be terminating or repeating.

A terminating bicimal has a finite number of bicimal places; a repeating bicimal (also known as a recurring bicimal or periodic bicimal) has an infinite number of bicimal places, due to a sequence of digits that repeat forever. There are two types of repeating bicimals: pure repeating (also known as immediate repeating or strictly repeating) and mixed repeating (also known as delayed repeating). In a pure repeating bicimal, the repeating part (also known as the repetend) starts immediately after the bicimal point. In a mixed repeating bicimal, a non-repeating part starts immediately after the bicimal point; it is then followed by a repeating part.

Here are some examples:

  • 0.1101 (a terminating bicimal).
  • 101.01 (a pure repeating bicimal).
  • 11.1110 (a mixed repeating bicimal).

Like decimals, bicimals are created from fractions through long division. Also like decimals, bicimals can be converted back to fractions. You convert a bicimal to a fraction the same way you convert a decimal to a fraction — you just work in binary instead of decimal, and use powers of two instead of powers of ten.

A terminating bicimal is easy to convert to a fraction: the numerator of the resulting fraction is the bicimal itself, treated as an integer; the denominator is 2n, where n is the number of bicimal places. For example, 0.1101 = 1101/24 = 1101/10000 (which in decimal equals 13/16 = 0.8125). (Notice how I mixed decimal and binary numerals. Although potentially confusing, it is common practice, and actually makes things easier. I will be doing this throughout the article.)

Repeating bicimals take more work to convert. There are several methods; I will describe the subtraction method.

Subtraction Method

In the subtraction method, you take a bicimal b and create an expression that subtracts out its repeating part, and then rewrite that expression so that b is expressed as a fraction. Specifically, you create two nonnegative power of two multiples of b, mb and nb, such that mbnb = i, where i is an integer. Using simple algebra, you rewrite this expression as a fraction: b(m-n) = i, or b = i/(m-n).

Here is a straightforward way to pick m and n. Let p be the length of the non-repeating part, and let r be the length of one cycle of the repeating part. Choose m = 2p+r, and choose n = 2p. These values of m and n shift b left by differing numbers of places, creating new bicimals with identical fractional parts but different integer parts. (For pure repeating bicimals, p will be 0 and thus n will be 1, so nb = b; that is, it’s not shifted.)

Examples

Example 1: 101.01 = 10000/11

Consider the pure repeating bicimal b = 101.01. Picking m = 22 = 4 shifts b left by two places, giving 10101.01. Now if we subtract b from that, we will remove the fractional part (leaving b as is means we’ve picked n = 20 = 1). Let’s show the subtraction algebraically, in mixed decimal and binary numerals:

mbnb

4bb = 10101.01 – 101.01

3b = 10000

11b = 10000

b = 10000/11

which in decimal equals 16/3 = 5.3.

Example 2: 11.1110 = 101111/1100

Consider the mixed repeating bicimal b = 11.1110. Picking m = 24 = 16 will shift b left by four places — pulling out the non-repeating part and one cycle of the repeating part — giving 111110.10. Picking n = 22 = 4 will shift a copy of b left by two places — pulling out just the non-repeating part — giving 1111.10. Now let’s do the algebra:

mbnb

16b – 4b = 111110.10 – 1111.10

12b = 101111

1100b = 101111

b = 101111/1100

which in decimal equals 47/12 = 3.916.

Examples Redone Using Only Binary Numerals

You can perform the subtraction method using only binary numerals (thanks James for the comment); I will redo the two examples in this way.

Example 1: 101.01 = 10000/11

mbnb

100bb = 10101.01 – 101.01

11b = 10000

b = 10000/11

Example 2: 11.1110 = 101111/1100

mbnb

10000b – 100b = 111110.10 – 1111.10

1100b = 101111

b = 101111/1100

A Way to Avoid Binary Arithmetic on the Left Hand Side

The binary subtraction on the left hand side of the equation can be avoided; let’s manipulate the left hand side algebraically (remember that m = 2p+r and n = 2p):

mbnb

2p+rb – 2pb

2p(2rbb)

2pb(2r – 1)

(2r – 1)2pb

You don’t need to do any arithmetic to compute (2r – 1)2p: it is a string of r 1s followed by p 0s. For example 1, r = 2 and p = 0 gives 11; for example 2, r = 2 and p = 2 gives 1100.

On Going Directly to a Fraction Written in Binary

If you look around the Web (for example, Wikipedia), you’ll see this procedure is typically used to convert a bicimal straight to a fraction written in decimal numerals. For example 2, the steps would be:

mbnb

16b – 4b = 111110.10 – 1111.10

12b = 47

b = 47/12

which you’d then say is 101111/1100 in binary.

Conceptually, I see the process as bicimal -> fraction written in binary -> fraction written in decimal -> decimal, which is why I prefer my presentation.

Equivalent Representations of 47/12, In Binary and Decimal

Equivalent Representations of 47/12, in Binary and Decimal

Other Methods

Read my articles about the direct method and the series method — two other ways to convert a bicimal to a fraction.

By Rick Regan (Copyright © 2013 Exploring Binary)

Converting a Bicimal to a Fraction (Subtraction Method)


Viewing all articles
Browse latest Browse all 17

Trending Articles