Main Page | Report this Page
Computers Forum Index  »  Computer Architecture - Arithmetic  »  ZONNC: Hiding the Sign of a Decimal Number
Page 1 of 1    

ZONNC: Hiding the Sign of a Decimal Number

Author Message
Quadibloc
Posted: Tue Jan 22, 2008 12:53 am
Guest
Generally, if a decimal number is represented by packed BCD, one of
the digits is used to represent the sign.

This is, of course, an unnecessary inefficiency. If packed decimal is
aligned on byte boundaries, so that the number of digits must be even,
with a minimum-length number of 256 digits, the inefficiency of
packed decimal, with 256 codes standing for 100 values, already leaves
enough excess room for the sign.

But how to encode the sign?

One could begin the byte with a sign bit, and then have the remaining
7 bits encode a value from 0 to 99 in binary.

Or the remaining 7 bits could encode the two digits using Chen-Ho
coding.

I had thought that if one gave up having the sign bit in a fixed
location, one could get a coding that was even simpler, although, come
to think of it, probably my coding, in its second improved version, is
not all that different from two-digit Chen-Ho coding.

ZONNC is described on the page

http://www.quadibloc.com/arch/ar0201.htm

and involves having the first digit of the number code for some
negative and positive values, as shown here for the improved version:

+0n -> 0n
+1n -> 1n
+2n -> 2n
+3n -> 3n
+4n -> 4n
+5n -> 5n
+6n -> 6n
+7n -> 7n
-0n -> 8n
-1n -> 9n
-2n -> An
-3n -> Bn
-4n -> Cn
-5n -> Dn
-6n -> En
-7n -> Fn

and the remaining values are encoded by making the second digit of the
number one of the unused values:

+8n -> nC
+9n -> nD
-8n -> nE
-9n -> nF

The basic principle is indeed much like Chen-Ho encoding, the only
advantage is that when the sign is folded in, things happen at the
four-bit digit boundary, improving readability. The original version
would involve more logic circuits, but has the advantage that +8n and
+9n encode to 8n and 9n, so that all numbers with an unused BCD value
are negative.

John Savard
 
 
Page 1 of 1    
All times are GMT
The time now is Sun Nov 29, 2009 1:53 pm