[seqfan] Re: Can this sequence be defined well: 7, 16, 34, ... ?

Alex Meiburg timeroot.alex at gmail.com
Wed Apr 29 00:14:16 CEST 2020


It is not particularly straightforward or natural. The number of bits, e.g.
32, is used as follows: 1 bit is for a sign; some number is used for the
exponent; the remaining are used to store the digits (technically called
the "coefficient", a decimal version of mantissa). This is the precision
you read (7, 16, 34). The digits are represented in groups of 3, so the
range 0-999, by a collection of 10 bits (so a theoretical range of 0-1023).
This a small waste, but simplifies calculations occurring in base 10. See
http://speleotrove.com/decimal/dbover.html

But there's an exception. The first digit (see the bottom of that page, or
http://speleotrove.com/decimal/dbspec.html ) is stored separately,
awkwardly sharing some space with the exponent. So the number of digits is
always 1 + 3*k, where k is how many groups of 10 bits are used for
precision.

This is where it gets, in theory, a bit arbitrary. In an m-bit decimal
floating point number, how many bits should be used for exponent, and how
many should be used for the coefficient? After some digging, I found the
following note, which cites an IEC 60559:
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1685.pdf

There is says that, in addition to DECIMAL32, DECIMAL64, and DECIMAL128,
there is a k-bit decimal format for any k that is a multiple of *32* and
>=128. This format always uses 15*k/16 - 10 bits of precision, and so has
9*k/32-2 bits of precision. Since allowed values of k go {32,64,128,
128+32, 128+2*32, 128+3*32, ...}, the precisions will continue to go up by
9. So if your intended sequence is "decimal digits of precision in IEEE 754
floating point decimal numbers", then the sequence be described by

a(1) = 7
a(2) = 16
a(n) = 7 + 9*n otherwise

In practice, I think no one would ever use decimal160, but there are some
places people use decimal256. So if you'd rather go by the more realistic
"decimal digits of precision in IEEE 754 floating point decimal numbers
with power-of-2 sizes", the sequence is

a(n) = 2^n * 9/2 - 2.

Up to you if these belong in the OEIS! They're not pretty, but they're
real-world.

-- Alexander Meiburg


On Tue, Apr 28, 2020 at 2:33 PM Alonso Del Arte <alonso.delarte at gmail.com>
wrote:

> According to the documentation for java.math.MathContext <
> https://docs.oracle.com/javase/7/docs/api/java/math/MathContext.html>, the
> confusingly named DECIMAL32 is good for 32 bits of precision, or 7 decimal
> digits; DECIMAL64 is good for 64 bits or 16 digits; and DECIMAL128 is good
> for 128 bits or 34 digits. I've verified in the Scala REPL that there's no
> DECIMAL256. But if there was, what would be its decimal digit precision?
>
> I thought maybe if I searched the OEIS for "7, 16, 34" I might find the
> answer. The set of search results is small, though just big enough for me
> to think that maybe I've overlooked the answer. Which would mean only one
> of the results has the answer.
>
> But perhaps that also assumes the sequence can be defined well and it's
> already in the OEIS. Can it be well-defined? If so, is it already in the
> OEIS? It it isn't, does it need to be?
>
> Al
> --
> Alonso del Arte
> Author at SmashWords.com
> <https://www.smashwords.com/profile/view/AlonsoDelarte>
> Musician at ReverbNation.com <http://www.reverbnation.com/alonsodelarte>
>
> --
> Seqfan Mailing list - http://list.seqfan.eu/
>



More information about the SeqFan mailing list