[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

decimal16



Don't get excited -- this is for entertainment only.  Happy holidays!

Nevertheless, I was thinking about what a 16-bit DFP format would look
like.  There are several possibilities, though all of them violate some
of the general rules that have been proposed (in particular, that the
size of decimal formats must be a multiple of 32 bits).

Decimal formats have a sign bit, a (w+5)bit combination field, and a
10J-bit trailing significand field; emax is supposed to be 3*2**(w-1),
and emin is supposed to be 1-emax.  It is not possible to satisfy all
of these at once.

One possibility is w=0, so the biased exponent is 0, 1 or 2, and the
precision is 4 digits (one declet).  Clearly the emax and emin rules
cannot be satisfied (emax would be 1.5, and the emin rule requires a
range that includes an even number of values, i.e. w>0).

Nevertheless, choosing emax=3 and emin=1 (yes, positive emin) seems
to produce a practical range of 0.01 to 9999.  Another possibility
is 0.001 to 999.9, which is nicely balanced (emax=2, emin=0).  The
only advantage of the first choice, and what made me think of it, is
a larger range in dollars and cents.  Older 754r drafts permitted
the choice emin = -emax, which would give 0.0001 to 99.99, a rather
ugly range (emax=1, emin=-1, range 0.001e-1 to 9.999e+1).  (Ok, I
realise that the emin rule is supposed to balance the *normal*
range, excluding subnormals.  But I like the fact that nearly all
numbers have an inverse without triggering overflow.)

I note that BID encoding would have no problem with this format:
coefficients up to 8191 would use short encoding, and long form
would reach 10215, easily accomodating 9999.


The other possibility is to give up on the 10J rule, and use w=3
with a shortened 7-bit "declet".  Unlike the original Chen-Ho
format, DPD encoding has the nice property that leading zeros are
preserved, so that 0-9 have at least 7 leading zeros in the declet,
and 0-99 have at least 3 leading zeros.  BID is of course perfectly
happy with any bit size in the trailing significand.

Now we can get a conforming exponent range: emax=4, emin=-3, and the
range of positive finite values is from 0.00001 to 99900.  Unlike my
earlier suggestion this format has missing integers (just like the
usual floating-point formats).  Precision is of course 3 digits now.
(In this format, BID would not need long format, as the short format
covers 0-1023, and only needs to cover 0-999.  The long format could
reach 1279 in this case: 280 redundant versions of zero!)

Enjoy!

Michel.
Sent: 2007-12-29 21:05:34 UTC


754 | revision | FAQ | references | list archive