473,412 Members | 2,306 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

(part 5) Dick Heathfield's book errors

Richard Heathfield said:
>>Mick Charles Beaver said:
>Hello,
>Would anyone know why the FreeBSD implementation of swab() uses an
unsigned long for its temporary variable when swapping bytes?
<snip>
although those casts are a bit pointless, aren't they?
From swab.c:

void
swab(const void * __restrict from, void * __restrict to, ssize_t len)
{
unsigned long temp;
int n;
char *fp, *tp;

n = len >1;
fp = (char *)from;
tp = (char *)to;

From Dick Heathfield's _C Unleashed_ Random() function
on pg. 406:

int Random(int n)
{
double d;

d = rand() / (RAND_MAX + 1.0);
d *= n;

return (int)d;
}

[H&S 9.8: "If a function has a declared return type T
that is not void, then the type of any expression appearing
in a return statement must be convertible to type T by
assignment, and that conversion in fact happens on return
in both Standard and traditional C.

Example
In a function with declared return type int, the
statement
return 23.1;
is equivalent to
return (int) 23.1;
which is the same as
return 23
"]

That cast in Random() is a bit pointless, isn't it? Any
defense about style or lint-like programs could equally
apply to the unnecessary casts in swab.c.

Yours,
Han from China

"It is likely that Schildt knows what a linked list is, and
it's even likely that he explains it well. What is
somewhat less likely is that his implementation is
robust." -- Richard Heathfield, 2000

Oct 29 '08 #1
8 1360
On Oct 29, 2:35*pm, Borked Pseudo Mailed <nob...@pseudo.borked.net>
wrote:

[snip]
From Dick Heathfield's _C Unleashed_ Random() function
on pg. 406:

int Random(int n)
{
* double d;

* d = rand() / (RAND_MAX + 1.0);
* d *= n;

* return (int)d;

}

[H&S 9.8: "If a function has a declared return type T
that is not void, then the type of any expression appearing
in a return statement must be convertible to type T by
assignment, and that conversion in fact happens on return
in both Standard and traditional C.

Example
* In a function with declared return type int, the
statement
* * *return 23.1;
is equivalent to
* * return (int) 23.1;
which is the same as
* * return 23
"]

That cast in Random() is a bit pointless, isn't it? Any
defense about style or lint-like programs could equally
apply to the unnecessary casts in swab.c.

Yours,
Han from China

"It is likely that Schildt knows what a linked list is, and
it's even likely that he explains it well. What is
somewhat less likely is that his implementation is
robust." -- Richard Heathfield, 2000
I can't believe I'm taking the time to respond to this trolling
jackass, but...

You *do* realize that Heathfield wasn't the only author of that book?
That he's just one of, what, 8 or 9 authors?

Again, why does Richard get all the anti-groupies, as opposed to Ben,
Steve, Keith, Eric, etc.?
Oct 29 '08 #2
John Bode wrote:
[...]
Again, why does Richard get all the anti-groupies, as opposed to Ben,
Steve, Keith, Eric, etc.?
Perhaps because Richard (as he has explained) is reluctant to
use the killfile. Can't speak for the others, but my killfile is
threatening to outgrow the SAN ...

--
Er*********@sun.com
Oct 29 '08 #3
John Bode <jfbode1...@gmail.comwrote:
Borked Pseudo Mailed <nob...@pseudo.borked.netwrote:
[snip]
Let's put it back...
Richard Heathfield said: [in another thread]
although those casts are a bit pointless, aren't they?
..._C Unleashed_ Random() function on pg. 406:
int Random(int n)
...
* return (int)d;

I can't believe I'm taking the time to respond to this
trolling jackass,
Even a 'trolling jackass' can ask valid questions. [I
guess I'm proof of that. ;-] Of course, I don't support
the motives or unconstructive manner in which 'Han from
China' asks them.
but...

You *do* realize that Heathfield wasn't the only author
of that book? That he's just one of, what, 8 or 9
authors?
True, but 7 or 8 of those 8 or 9 only appear as 'et al'
on the front cover. I believe Lawrence was the main proof
reader, however that only makes the question more valid.
[Though not necessarily interesting.]

--
Peter
Oct 29 '08 #4
On 29 Oct 2008 at 20:29, John Bode wrote:
Again, why does Richard get all the anti-groupies, as opposed to Ben,
Steve, Keith, Eric, etc.?
Perhaps because while those other people can sometimes be unhelpful,
irritating, pedantic ninnies, only Heathfield is a megalomaniac?

Oct 30 '08 #5
On Wed, 29 Oct 2008 13:29:33 -0700 (PDT), John Bode
<jf********@gmail.comwrote in comp.lang.c:
On Oct 29, 2:35*pm, Borked Pseudo Mailed <nob...@pseudo.borked.net>
wrote:

[snip]
From Dick Heathfield's _C Unleashed_ Random() function
on pg. 406:

int Random(int n)
{
* double d;

* d = rand() / (RAND_MAX + 1.0);
* d *= n;

* return (int)d;

}

[H&S 9.8: "If a function has a declared return type T
that is not void, then the type of any expression appearing
in a return statement must be convertible to type T by
assignment, and that conversion in fact happens on return
in both Standard and traditional C.

Example
* In a function with declared return type int, the
statement
* * *return 23.1;
is equivalent to
* * return (int) 23.1;
which is the same as
* * return 23
"]

That cast in Random() is a bit pointless, isn't it? Any
defense about style or lint-like programs could equally
apply to the unnecessary casts in swab.c.

Yours,
Han from China

"It is likely that Schildt knows what a linked list is, and
it's even likely that he explains it well. What is
somewhat less likely is that his implementation is
robust." -- Richard Heathfield, 2000

I can't believe I'm taking the time to respond to this trolling
jackass, but...

You *do* realize that Heathfield wasn't the only author of that book?
That he's just one of, what, 8 or 9 authors?

Again, why does Richard get all the anti-groupies, as opposed to Ben,
Steve, Keith, Eric, etc.?
I agree, I'm starting to feel neglected.

Surely there's _something_ wrong with Chapter 18?

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
Oct 30 '08 #6
Peter Nilsson said:

<snip>
Even a 'trolling jackass' can ask valid questions. [I
guess I'm proof of that. ;-] Of course, I don't support
the motives or unconstructive manner in which 'Han from
China' asks them.
Neither do I, which is why I'm not answering them.

<snip>
I believe Lawrence was the main proof
reader, however that only makes the question more valid.
[Though not necessarily interesting.]
It's not a terribly interesting question. It is, however, a valid question.
The answer, however, is no - Lawrence wasn't the main proofreader. If he
had been, it would have been an even better book (but on the other hand,
we were already riding roughshod over deadlines as it was).

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Oct 30 '08 #7
Jack Klein said:

<snip>
>
Surely there's _something_ wrong with Chapter 18?
There are 29 reported errata, most being minor typographical errors.

Some of the errata were reported by a Mr J Klein. :-)

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Oct 30 '08 #8
On Oct 30, 5:32*am, Richard Heathfield <r...@see.sig.invalidwrote:
Peter Nilsson said:

<snip>
Even a 'trolling jackass' can ask valid questions. [I
guess I'm proof of that. ;-] Of course, I don't support
the motives or unconstructive manner in which 'Han from
China' asks them.

Neither do I, which is why I'm not answering them.

<snip>
I believe Lawrence was the main proof
reader, however that only makes the question more valid.
[Though not necessarily interesting.]

It's not a terribly interesting question. It is, however, a valid question.
The answer, however, is no - Lawrence wasn't the main proofreader. If he
had been, it would have been an even better book (but on the other hand,
we were already riding roughshod over deadlines as it was).
I had two proof readers for chapter 13.
One proofreader was an employee of the book company.
The second proofreader was...
Peter Seebach!
Maybe he was looking for IAQ entries.
;-)
Oct 30 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

97
by: Master Programmer | last post by:
Thinking of learning VB.NET? New programmer? Thinking of Moving over from VB 6.0? Read on friend, let me help you make a more informed decision......... Microsoft are a pathetic company,...
334
by: Antoninus Twink | last post by:
The function below is from Richard HeathField's fgetline program. For some reason, it makes three passes through the string (a strlen(), a strcpy() then another pass to change dots) when two would...
0
by: Nomen Nescio | last post by:
hay, student proggramer 19 yrs old china in computer course ben doing c proggraming cpl of months from pascal backgrond enjoyying c unleashed book posible minour buggs found in dick heathfields...
3
by: George Orwell | last post by:
hay, Han frm china heer again... ben readin sum more c unleashed book dick heathfields book... still readin dick heathfields data structs cht but jumped ahead to chad dixons cgi proggraming cht...
8
by: Nomen Nescio | last post by:
Hey, this is Ajun from a Bangladesh outsource company. Han has hired me to do the English writing for his comp.lang.c posts. The subject line has been changed, which may affect archival...
4
by: Nomen Nescio | last post by:
No errors to report here. It's hard work taking the nitpick microscope to the CLC Clique's book, but someone has to do it. It's occurred to me I haven't properly introduced myself. /* *...
1
by: Lew Pitcher | last post by:
On October 29, 2008 19:30, in comp.lang.c, Nomen Nescio (nobody@dizum.com) wrote: Well, you said it: "This is nitpick central". I have a nit to pick. According to the C99 standard, the macro...
1
by: Borked Pseudo Mailed | last post by:
Hey, guys. I'm still plowing through Dick Heathfield's data-structures chapter. It's like reading 100-plus pages on how to core an apple, but I'm getting there, slowly. I'm up to his HTML syntax...
5
by: Chris M. Thomasson | last post by:
"George Orwell" <nobody@mixmaster.itwrote in message news:c6eb564c3d719950dc8bd7151040c449@mixmaster.it... Do you really think a single book provides enough weight for proper workout...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.