Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Even more errors in Schildt's books.

2 views
Skip to first unread message

Seebs

unread,
Apr 6, 2010, 6:51:14 PM4/6/10
to
Here's what got me. I had the book still open to page 464 (from looking
something up), and happened to glance over at 465.

strtoll
#include <stdlib.h>
long long int strtoll(const char * restrict start,
char ** restrict end, int radix);

strtoll() was added by C99.

The strtoll() function is similar to strtol() except that it
returns a long long int. If the result cannot be represented
by a long integer, LLONG_MAX or LLONG_MIN is returned, and the
global errno is set to ERANGE, indicating a range error. If
start does not point to a number, no conversion takes place and
zero is returned.

(Side note: strtol() doesn't have restrict in C:TCR, but the text explains
that it does in C99, so that's fine.)

Consider, if you will, a machine on which LLONG_MAX > LONG_MAX, and a
call to strtoll() with a string containing a value equal to LONG_MAX + 1.
According to Schildt, it will return LLONG_MAX. :)

Now, this is pretty trivial to figure out -- clearly, a cut and paste
followed by not editing. Still, I think this suggests that maybe it's time
to come up with some kind of taxonomy for these errors, so we can sort
them by type, severity, or humor value.

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / usenet...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!

spinoza1111

unread,
Apr 6, 2010, 9:01:21 PM4/6/10
to
On Apr 7, 6:51 am, Seebs <usenet-nos...@seebs.net> wrote:
> Here's what got me.  I had the book still open to page 464 (from looking
> something up), and happened to glance over at 465.
>
>         strtoll
>                 #include <stdlib.h>
>                 long long int strtoll(const char * restrict start,
>                         char ** restrict end, int radix);
>
>         strtoll() was added by C99.
>
>         The strtoll() function is similar to strtol() except that it
>         returns a long long int.  If the result cannot be represented
>         by a long integer, LLONG_MAX or LLONG_MIN is returned, and the
>         global errno is set to ERANGE, indicating a range error.  If
>         start does not point to a number, no conversion takes place and
>         zero is returned.
>
> (Side note:  strtol() doesn't have restrict in C:TCR, but the text explains
> that it does in C99, so that's fine.)
>
> Consider, if you will, a machine on which LLONG_MAX > LONG_MAX, and a
> call to strtoll() with a string containing a value equal to LONG_MAX + 1.
> According to Schildt, it will return LLONG_MAX.  :)
>
> Now, this is pretty trivial to figure out -- clearly, a cut and paste
> followed by not editing.  Still, I think this suggests that maybe it's time
> to come up with some kind of taxonomy for these errors, so we can sort
> them by type, severity, or humor value.

You fail to notice that Schildt is using "long integer" in its
contemporaneous sense because unlike you, he's a professional
programmer and knows several languages...whereas it appears to us that
you do not in actuality know C in the sense of being able to come up
with any competent code.

At this time, "long integer" where "integer" is spelled out doesn't
mean the same thing as "long int" in C. "long int" in C means a 32 bit
integer. Whereas "long" on contemporary platforms means a 64 bit
integer...what C calls a long long integer.

You have told us you're autistic with ADHD and "not
neurotypical" (http://www.seebs.net/log/articles/460/thoughts-on-
neurotypicality-), and you've asked, implicitly, for our charity for
having such a fashionable disease, which we'd be delighted to extend
except for the fact that you do not show that charity at all towards
others.

But: if you learn and perform is a way that is so very Special, your
theories of learning and education are useless to us. Schildt is
addressing, in some measure, people who come to C from languages where
a long integer, where integer is spelled out, is today 64 bits. "long
long" is idiomatic to C and used nowhere else.

>
> -s
> --
> Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nos...@seebs.nethttp://www.seebs.net/log/<-- lawsuits, religion, and funny pictureshttp://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!

DDD

unread,
Apr 6, 2010, 11:16:21 PM4/6/10
to
In a nut shell, long integer is not "long int"?

SG

unread,
Apr 6, 2010, 11:46:55 PM4/6/10
to
spinoza1111 wrote:
> You fail to notice that Schildt is using "long integer" in its
> contemporaneous sense because unlike you, he's a professional
> programmer and knows several languages...whereas it appears to
> us

Speak for yourself. It appears to me that Schildt could and should
have been much more precise (once again). All to often you include
everybody else in an "us" or "we" but most readers probably wouldn't
agree with you. No, I also can't speak for everybody else. It's just
my estimation of the situation.

> [...] "long int" in C means a 32 bit integer.

Since when? You do know that a "long int" in the LP64 model (like GCC
uses for 64bit Linux) is actually a 64 bit integer, right?

> Whereas "long" on contemporary platforms means a 64 bit
> integer...what C calls a long long integer.

Saying "long integer" to mean "long long int" it not at all obvious.
But it /is/ obvious that it /can/ be misinterpreted which is why
Schildt should have been more precise. Also, of course, C only
specifies minimum sizes (char at least 8 bits, short at least 16, int
at least 16, long at least 32, long long at least 64) -- at least in
the case of ISO/ANSI C. I don't know what kind of C you and Schildt
have in mind.

Ian Collins

unread,
Apr 7, 2010, 12:13:38 AM4/7/10
to
On 04/ 7/10 01:01 PM, spinoza1111 wrote:
> On Apr 7, 6:51 am, Seebs<usenet-nos...@seebs.net> wrote:
>>
>> Now, this is pretty trivial to figure out -- clearly, a cut and paste
>> followed by not editing. Still, I think this suggests that maybe it's time
>> to come up with some kind of taxonomy for these errors, so we can sort
>> them by type, severity, or humor value.
>
> You fail to notice that Schildt is using "long integer" in its
> contemporaneous sense

<insulting twaddle snipped>

Nonsense.

> At this time, "long integer" where "integer" is spelled out doesn't
> mean the same thing as "long int" in C. "long int" in C means a 32 bit
> integer. Whereas "long" on contemporary platforms means a 64 bit
> integer...what C calls a long long integer.

Complete bollocks. It has no such meaning on any platform I use.

>> -s
>> --
>> Copyright 2010, all wrongs reversed. Peter Seebach / usenet-nos...@seebs.nethttp://www.seebs.net/log/<-- lawsuits, religion, and funny pictureshttp://en.wikipedia.org/wiki/Fair_Game_(Scientology)<-- get educated!

Any professional programmer with a double digit IQ can learn how to snip
Usenet posts.

--
Ian Collins

Keith Thompson

unread,
Apr 7, 2010, 12:19:56 AM4/7/10
to
DDD <198...@gmail.com> writes:
> In a nut shell, long integer is not "long int"?
[...]

Maybe.

C uses the term "integer" to refer to a set of types, including
char, short, int, long, long long, unsigned varieties of each
(plus signed char), and possibly more. The type "int" is just one
of the integer types.

The word "int" is clearly an abbreviation of "integer", but the terms
"int" and "integer" mean quite different things.

C doesn't use the term "long integer". A writer who uses that phrase
in a C context *probably* means "long int", though it's conceivable
that he means something else. In any case it's nearly certain that
he should have used a less ambiguous phrase.

As for what Schildt meant by "long integer" in this particular
context, his description of strtoll(), a look at his description
of strtol() would probably be instructive. I don't have the book,
but my guess is that he also used the term "long integer" in the
description of strtol(), and that it obviously referred to the type
"long int".

--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"

Seebs

unread,
Apr 7, 2010, 12:22:06 AM4/7/10
to
On 2010-04-07, Keith Thompson <ks...@mib.org> wrote:
> As for what Schildt meant by "long integer" in this particular
> context, his description of strtoll(), a look at his description
> of strtol() would probably be instructive. I don't have the book,
> but my guess is that he also used the term "long integer" in the
> description of strtol(), and that it obviously referred to the type
> "long int".

It's surprisingly inconsistent.

The corresponding language:

strtod: If overflow occurs...
strtof: If overflow occurs...
strtol: If the result cannot be represented by a *long int*...
strtold: If over flow occurs...
strtoll: If the result cannot be represented by a long integer...
strtoul: If the result cannot be represented as an unsigned long integer...
strtoull: If the result cannot be represented as an unsigned long integer...

"*long int*" represents something bolded.

Conclusion: We do not have enough information to be totally sure of
what this meant. I don't know why the unsigned ones get "as"
instead of "by". It's clearly erratic editing.

However, this is unwinnable for Schildt. If "long integer" means any
of the integer types which are longer than int, then strtoul's description
is incorrect. If it means long specifically, as opposed to long long,
then the descriptions of strtoll and strtoull are wrong.

-s
--

Richard Heathfield

unread,
Apr 10, 2010, 5:15:06 PM4/10/10
to
Seebs wrote:

"Even more errors in Schildt's books." [Subject header]

News flash: even more water in sea. Film at 11.

<snip>

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
"Usenet is a strange place" - dmr 29 July 1999
Sig line vacant - apply within

0 new messages