Page 250 - ARM 64 Bit Assembly Language
P. 250
CHAPTER 8
Non-integral mathematics
Chapter 7 introduced methods for performing computation using integers. Although many
problems can be solved using only integers, it is often necessary (or at least more convenient)
to perform computation using real numbers or even complex numbers. For our purposes, a
non-integral number is any number that is not an integer. Many systems are only capable of
performing computation using binary integers, and have no hardware support for non-integral
calculations. In this chapter, we will examine methods for performing non-integral calcula-
tions using only integer operations.
8.1 Base conversion of fractional numbers
Section 1.3.2 explained how to convert integers in a given base into any other base. We will
now extend the methods to convert fractional values. In radix point notation, a fractional num-
ber can be viewed as consisting of an integer part, a radix point, and a fractional part. In base
10, the radix point is also known as the decimal point. In base 2, it is called the binimal point.
For base 16, it is the heximal point, and in base 8 it is an octimal point. The term radix point
is used as a general term for a location that divides a number into integer and fractional parts,
without specifying the base.
8.1.1 Arbitrary base to decimal
The procedure for converting fractions from a given base b into base ten is very similar to the
procedure used for integers. The only difference is that the digit to the left of the radix point
0
is weighted by b and the exponents become increasingly negative for each digit right of the
radix point. The basic procedure is the same for any base b. For example, the value 101.0101 2
can be converted to base ten by expanding it as follows:
0
2
1
1 × 2 + 0 × 2 + 1 × 2 + 0 × 2 −1 + 1 × 2 −2 + 0 × 2 −3 + 1 × 2 −4
1 1
= 4 + 0 + 1 + 0 + + 0 +
4 16
= 5.3125 10
Likewise, the hexadecimal fraction 4F2.9A0 can be converted to base ten by expanding it as
follows:
0
1
2
4 × 16 + 15 × 16 + 2 × 16 + 9 × 16 −1 + 10 × 16 −2 + 0 × 16 −3
ARM 64-Bit Assembly Language
https://doi.org/10.1016/B978-0-12-819221-4.00015-8 239
Copyright © 2020 Elsevier Inc. All rights reserved.