Java Reference
In-Depth Information
can be any of the digits allowed for the base B (e.g. 0 or 1
for the binary base). The value represented by the number above can be
calculated with the following formula:
Each cipher c i
=
i
n
B i
m  
c i
·
Equation 6.1 Value of a number in base B
The initial and final indices of the ciphers ( n and 0 m in Equation 6.1) are
determined on the basis of the position of the dot that separates the integer
part from the fractional part. The cipher immediately preceding it has index
0 (i.e. will be multiplied for the base raised to the power of 0 that is equiva-
lent to 1 for any base). The ciphers preceding the “.” assume increasing
indices as they move away from it. The opposite holds for the ciphers
following the decimal point.
For instance, we can calculate as follows the value represented by a
number in base 10:
1
2
10 1
10 0
10 1
12.5 decimal =
1
·
+
2
·
+
5
·
=
10
+
2
+
And for a base 2 number:
1
2
2 3
2 2
2 1
2 0
2 1
1100.1 binary =
1
·
+
1
·
+
0
·
+
0
·
+
1
·
=
8
+
4
+
And for a base 16 number:
1
2
16 0
16 1
C .8 hexadecimal =
12
·
+
8
·
=
12
+
To find the representation of a given number according to a base B we
have to find the initial and final indices and compute all the ciphers corre-
sponding to such a range of indices.
Since the decimal point is essential in defining the value of a number, it
must always be included in the representation. As a consequence the initial
index cannot be lower than 0 and the final index cannot be greater than 01.
The only exception to this rule is when there is only a “0” after the decimal
point; in this case both the decimal point and the “0” can be omitted. This is
the case of integer numbers.
The initial index n for a number can be found as:
n
=
log B ( number )
Equation 6.2 Initial cipher index for representation in base B
while the final index m can be found as:
1
number
m
=−
log B
Equation 6.3 Final cipher index for representation in base B
Search WWH ::




Custom Search