Strange bit corruption in a double

D

Dik T. Winter

>
> Thanks, everyone, for your help. When I printf with %.15e,
> I get 4.273558636127927e-305. Looks like there is problem
> with that variable somewhere else. I didn't know about the %e
> and %g flags, so thanks for showing that.

Much more likely is that the answer is correct, but that due to rounding
the small error comes in.
 
L

Lane Straatman

Richard Heathfield said:
Lane Straatman said:


man indent if you care enough. Yes, whitespace matters, but it can be
added
automatically and trivially to your exact requirements. I have my own
whitespace preferences, which not everybody shares, but "layout not in
accord with my preferences" and "sloppy-looking" are different concepts.
Keith pointed that the format specifier was the fix-it, which is the first
thing I suspected, not knowing any of the specifiers involved. The only
reason I reply was to say I thought this thread is becoming hilarious and
interesting. I want to ask what the range and bias mean, but I don't want
to butt in while they're figuring it out. LS
 
E

Ernie Wright

Joe said:
It depends on where you think the binary point is.

If we want to talk about floating-point in a way that's consistent with
the existing standards, we aren't free to move it around.

There's a reason it's put in a specific place. In decimal,

1.0 x 10^0
0.1 x 10^1
0.01 x 10^2
10.0 x 10^-1

are obviously all the same number. In fact, there are an infinite
number of ways to write this number by moving the decimal point and
adjusting the exponent. In order to agree on a unique representation,
we need an additional constraint: we require that the significand (the
first part) satisfy

1 <= significand < base

This particular representation is said to be normalized.

If you ignore this convention, you'll have a much harder time following
the discussion of IEEE 754, particularly about things like denormals.

- Ernie http://home.comcast.net/~erniew
 
J

Joe Wright

Ernie said:
If we want to talk about floating-point in a way that's consistent with
the existing standards, we aren't free to move it around.

There's a reason it's put in a specific place. In decimal,

1.0 x 10^0
0.1 x 10^1
0.01 x 10^2
10.0 x 10^-1

are obviously all the same number. In fact, there are an infinite
number of ways to write this number by moving the decimal point and
adjusting the exponent. In order to agree on a unique representation,
we need an additional constraint: we require that the significand (the
first part) satisfy

1 <= significand < base

This particular representation is said to be normalized.

If you ignore this convention, you'll have a much harder time following
the discussion of IEEE 754, particularly about things like denormals.

- Ernie http://home.comcast.net/~erniew

I learned what I know about floating point at Philco Computers tech
school in 1963. We started with the proposition that the mantissa was a
fraction, always less than 1. Consider..

01000000 00010100 00000000 00000000 00000000 00000000 00000000 00000000
Exp = 1025 (3)
000 00000011
Man = .10100 00000000 00000000 00000000 00000000 00000000 00000000
5.0000000000000000e+00

...The mantissa must be .101 in my case and the biased exponent must be
3. I have seen some IEEE description of this value as 1.01 with a biased
exponent of 2. I can see their point. I can go either way.
 
E

Ernie Wright

Joe said:
I learned what I know about floating point at Philco Computers tech
school in 1963. We started with the proposition that the mantissa was
a fraction, always less than 1.

I'm pretty sure this is why the neologism "significand" was invented for
this component of the number, to avoid overloading "mantissa."

Pre-computer, as I'm sure you know, the mantissa was the fractional part
of a common (base-10) logarithm. My recollection from school is that
"mantissa" was also the name given to the coefficient (the left side) of
a number written in scientific notation.

If the scientific notation coefficient is normalized (it's between 1 and
the base), then the log of the coefficient is the mantissa of the log of
the number. For example, 1500 in scientific notation is

1.5 x 10^3

The coefficient is 1.5. log10( 1.5 ) = 0.1761. log10( 1500 ) = 3.1761.
The mantissa of log10( 1500 ) is equal to log10( 1.5 ).

So we have two definitions of "mantissa":

1. the fractional part of a logarithm
2. the coefficient of a number in scientific notation

These are clearly different things, but we can "align" the two meanings
by assuming that coefficients are normalized. The coefficient is then
the antilog of the definition-1 mantissa.

The significand in the binary representation of IEEE floating-point
numbers is *not* the definition-1 mantissa. It's the coefficient, and
for the sake of simplicity, it's conventionally the *normalized* one.
Conventionally, because it obviously doesn't make any difference
numerically if we move the radix point and adjust the exponent
accordingly.

For what it's worth, I learned about floating-point formats in 1985 or a
little before. That was the year I took a VAX assembly language class.

- Ernie http://home.comcast.net/~erniew
 
B

Ben Pfaff

Ernie Wright said:
I'm pretty sure this is why the neologism "significand" was invented for
this component of the number, to avoid overloading "mantissa."

Pre-computer, as I'm sure you know, the mantissa was the fractional part
of a common (base-10) logarithm. My recollection from school is that
"mantissa" was also the name given to the coefficient (the left side) of
a number written in scientific notation.

According to Wikipedia, from the article on "significand":

Use of "mantissa"

main article: mantissa

The original word used in American English to describe the
coefficient of floating-point numbers in computer hardware, later
called the significand, seems to have been mantissa (see Burks et
al., below), and as of 2005 this usage remains common in
computing and among computer scientists. However, this use of
mantissa is discouraged by the IEEE floating-point standard
committee and by some professionals such as William Kahan and
Donald Knuth, because it conflicts with the pre-existing usage of
mantissa for the fractional part of a logarithm (see also common
logarithm).

The older meaning of mantissa is related to the IEEE's
significand in that the fractional part of a logarithm is the
logarithm of the significand for the same base, plus a constant
depending on the normalization. (The integer part of the
logarithm requires no such manipulation to relate to the
floating-point exponent.)

The logarithmic meaning of mantissa dates to the 18th century
(according to the OED), from its general English meaning (now
archaic) of "minor addition", which stemmed from the Latin word
for "makeweight" (which in turn may have come from
Etruscan). Significand is a 20th century neologism.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top