Error in K&R 2?

C

cristofd

This is not mentioned in the official list at
http://cm.bell-labs.com/cm/cs/cbook/2ediffs.html.
On page 257, FLT_MAX_EXP is defined as
"maximum n such that (FLT_RADIX^n)-1 is representable"
(at least, that's the closest I can express it in ASCII); whereas it
should be
"maximum n such that FLT_RADIX^(n-1) is representable"
(i.e., the "-1" should be in superscript along with the "n").
In fact, if I have things straight, the definition in the book would
make FLT_MAX_EXP essentially a synonym for FLT_MANT_DIG. The same goes
for DBL_MAX_EXP on page 258. Am I missing something, or is this an
error they should be informed of?

-Daniel.
 
R

Richard Bos

This is not mentioned in the official list at
http://cm.bell-labs.com/cm/cs/cbook/2ediffs.html.
On page 257, FLT_MAX_EXP is defined as
"maximum n such that (FLT_RADIX^n)-1 is representable"
(at least, that's the closest I can express it in ASCII); whereas it
should be
"maximum n such that FLT_RADIX^(n-1) is representable"
(i.e., the "-1" should be in superscript along with the "n").
In fact, if I have things straight, the definition in the book would
make FLT_MAX_EXP essentially a synonym for FLT_MANT_DIG. The same goes
for DBL_MAX_EXP on page 258. Am I missing something, or is this an
error they should be informed of?

I haven't got K&R to hand, but as for the Standard parts of this, no,
you haven't missed anything. FLT_MAX_EXP should indeed mean "maximum n
such that FLT_RADIX^(n-1) is representable" and not "maximum n such that
(FLT_RADIX^n)-1 is representable"; and that latter is not by definition,
but AFAICT is in effect, equal to FLT_MANT_DIG.
And yes, if you haven't misread K&R and this error is indeed in K&R2,
then IMO they should be informed.

Richard
 
D

dandelion

Richard Bos said:
I haven't got K&R to hand, but as for the Standard parts of this, no,
you haven't missed anything. FLT_MAX_EXP should indeed mean "maximum n
such that FLT_RADIX^(n-1) is representable" and not "maximum n such that
(FLT_RADIX^n)-1 is representable"; and that latter is not by definition,
but AFAICT is in effect, equal to FLT_MANT_DIG.
And yes, if you haven't misread K&R and this error is indeed in K&R2,
then IMO they should be informed.

Richard

Now *that's* a usefull answer. Thanks.
 
K

KiLVaiDeN

This is not mentioned in the official list at
http://cm.bell-labs.com/cm/cs/cbook/2ediffs.html.
On page 257, FLT_MAX_EXP is defined as
"maximum n such that (FLT_RADIX^n)-1 is representable"
(at least, that's the closest I can express it in ASCII); whereas it
should be
"maximum n such that FLT_RADIX^(n-1) is representable"
(i.e., the "-1" should be in superscript along with the "n").
In fact, if I have things straight, the definition in the book would
make FLT_MAX_EXP essentially a synonym for FLT_MANT_DIG. The same goes
for DBL_MAX_EXP on page 258. Am I missing something, or is this an
error they should be informed of?

-Daniel.

You could maybe get Christmas chocolate for pointing that error out ;)

K
 
C

Christopher Benson-Manica

Richard Bos said:
And yes, if you haven't misread K&R and this error is indeed in K&R2,
then IMO they should be informed.

I can see the text OP described on page 258, so it would appear that
the error does, in fact, exist.
 
C

cristofd

Christopher said:
I can see the text OP described on page 258, so it would appear that
the error does, in fact, exist.
Thanks. I've emailed them about it.
-Daniel.
 
C

cristofd

Christopher said:
Thanks. I've emailed them about it.
-Daniel.

DMR just added it to the list of errata. It turns out that the original
ANSI standard was ambiguous on this point:

maximum integer such that FLT_RADIX raised to that
power minus 1 is a representable....

-Daniel.
 
C

Christopher Benson-Manica

(e-mail address removed) spoke thus:
DMR just added it to the list of errata. It turns out that the original
ANSI standard was ambiguous on this point:
maximum integer such that FLT_RADIX raised to that
power minus 1 is a representable....

Were you awarded a medal? ;) Well done.
 

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,156
Messages
2,570,878
Members
47,413
Latest member
KeiraLight

Latest Threads

Top