10 Arithmetic using Hensel Codes
The rules of the arithmetic are similar to the infinite-precision case. However,
notice that whenever
the result is outside the set
, uniqueness
and correctness are no longer assured. The table given
be low enumerates all Hensel codes of the form H(5, 4, a/b) where a/b ∈
.
Table 1: Ordinary Hensel Codes H(5, 4, a/b)

Using this table, we now illustrate some of the properties
of the finite segment p-adic number
systems:
• Let α = 2/3 and β = 3/4. The result is 2/3 + 3/4 =
17/12.

which is found in the table, giving the correct result.
• Let α = 3/13 and β = 1/12. The result is 3/13 + 1/12 = 49/156.

which is not in the table.
• Let α = 5/2 and β = 5/7. The result is 5/2 + 5/7 = 45/14.

which is in the table, giving an incorrect result 10/17.
Note that 10/17 = 0.588235 is far from
the correct result 45/14 = 3.21429 in the absolute norm. However, it is
5-adically close, i.e.,
their difference 10/17 − 45/14 = −625/238 is divisible by
.
Theorem 2 Let α = a/b and β = c/d, with gcd(b, p) =
gcd(d, p) = 1. Then H(p, r, α) = H(p, r, β)
if and only if

or, in other words,

Using the previous example α = 10/17 and β = 45/14, we see
that

i.e.,
10 · 14 = 45 · 17 (mod 625) .
11 Floating-Point Hensel Codes
Let
with gcd(c, d) = gcd(c, p) = gcd(d, p)
= 1, then the normalized floating-point
Hensel code of α is defined as the pair
(p,
r, α) = (m, e) such that m = H(p, r, c/d) and e = n.
Here m is the onents .html">mantissa and e is the exponent . For example,

12 Arithmetic using Floating-Point Hensel Codes
Consider the following example:
. The Hensel
codes are given as

First, we line up the p-adic points: (.1000,−1) = (1.000,
0) and then perform the addition

Hence, the sum is equal to (1.413, 0) = (.1413,−1) which
is equal to 13/15.
Subtraction is performed by using “complemented addition” in the sense that the
subtrahend
is complemented and added to the minuend . For example, to compute
using Hensel
codes, we need
(5, 4,−1/5) = (.4444,−1). We
ration s.html">perform the operation

which gives (4.313, 0) = (.4313,−1), i.e., the Hensel code
of 7/15.
For multiplication, consider the example:
.

The algorithm multiplies the mantissas

and adds the exponents: 0+(−1) = −1. Thus,
(5, 4, α) = (.2000,−1) which is equal to 2/5
since
ordinary Hensel code of 2/5 is equal to 2.000.
13 Normalization of Floating-Point Hensel Codes
Consider the following operation 1/2+1/8 = 5/8 using floating-point Hensel
codes,
(5, 4, 1/2) =
(.3222, 0) and
(5, 4, 1/8) = (.2414, 0).

The table indicates that this is indeed the ordinary
Hensel code of 5/8. However, we need to
compute its floating-point Hensel code of the form (.xyyy, e) where x is
non zero . How can this be
achieved? The following method is proposed:
Gregory & Krishnamurty: Convert the unnormalized Hensel code to its order
N Farey fraction
and then map this number to its normalized floating-point Hensel code. For
example, the
table indicates that .0241 is equal to 5/8. We then compute (using the table)
the Hensel code
of 1/8 as .2414 which means the floating-point Hensel code of
is equal to (.2414, 1).
Colagrossi & Miola: Soon to be investigated.
14 Research Directions
• Area and time complexity of the binary versus p-adic floating-point number
systems .
• Efficient algorithms for conversion, magnitude detection, and normalization of
Hensel codes.
• Detection of overflow and underflow.
• Applications of p-adic arithmetic in computational algebra and scientific
computing.
More about p-adic arithmetic and Hensel codes can be found in the following
books [1, 4, 6] and
the papers [8, 5, 3, 10, 11, 7, 12, 13, 9, 2].