[Numpy-discussion] Log Arrays

Anne Archibald peridot.faceted@gmail....
Thu May 8 13:39:58 CDT 2008


2008/5/8 Charles R Harris <charlesr.harris@gmail.com>:
>
> David, what you are using is a log(log(x)) representation internally. IEEE
> is *not* linear, it is logarithmic.

As Robert Kern says, yes, this is exactly what the OP and all the rest
of us want.

But it's a strange thing to say that IEEE is logarithmic - "2.3*10**1"
is not exactly logarithmic, since the "2.3" is not the logarithm of
anything. IEEE floats work the same way, which is important, since it
means they can exactly represent integers of moderate size. For
example, 257 is represented as

sign 0, exponent 135, (implied leading 1).00000001b.

The exponent is indeed the integer part of the log base 2 of the
value, up to some fiddling, but the mantissa is not a logarithm of any
kind.

Anyway, all this is immaterial. The point is, in spite of the fact
that floating-point numbers can represent a very wide range of
numbers, there are some important contexts in which this range is not
wide enough. One could in principle store an additional power of two
in an accompanying integer, but this would be less efficient in terms
of space and time, and more cumbersome, when for the usual situations
where this is applied, simply taking the logarithm works fine.

Anne


More information about the Numpy-discussion mailing list