M
Mark McIntyre
I've got to figure something out for future posts. What I see and what I
post are radically different.
Your news software is converting tabs into spaces. Don't use tabs in posts
to usenet.
I've got to figure something out for future posts. What I see and what I
post are radically different.
Keith Thompson said:That's mostly good advice, but it shouldn't be applied universally.
Some abbreviations are so obvious that it doesn't make sense to expand
them, such as "IO" rather than "input_output". (And if I were writing
code that handled PCMCIA devices, I wouldn't even know how to expand
the abbreviation; all I can remember is "People Can't Memorize
Computer Industry Acronyms".)
The set of abbreviations that are sufficiently obvious depends
strongly on the domain and the expected audience. In my work, "GPT"
and "GSI" are obvious; most people who don't know what they stand for
are unlikely to want to read my code anyway.
Unfortunately, most people tend to err in the direction of
abbreviating too much.
HTH, HAND, YMMV.
[...] >Time Rentsch:That's mostly good advice, but it shouldn't be applied universally.A couple of the names use abbreviations as part of the name (eg,
'fam_size'). I recommend using the whole word, and always avoiding
abbreviations. It takes a certain amount of intestinal fortitude to
do this, as the temptation to make exceptions is strong (but don't
give in!). The more I follow this practice the more I see the
benefits. For function local variables, it's common to allow single
letters to be used as "words"; these aren't abbreviations in the
sense meant here.
Some abbreviations are so obvious that it doesn't make sense to expand
them, such as "IO" rather than "input_output". (And if I were writing
code that handled PCMCIA devices, I wouldn't even know how to expand
the abbreviation; all I can remember is "People Can't Memorize
Computer Industry Acronyms".)
The set of abbreviations that are sufficiently obvious depends
strongly on the domain and the expected audience. In my work, "GPT"
and "GSI" are obvious; most people who don't know what they stand for
are unlikely to want to read my code anyway.
"Tim Rentsch wrote:
Sorry, I should have made this more clear in my original writing. I
distinguish between using "abbreviations", by which I mean a
shortening of a word, and using "acronyms", by which I mean a "word"
formed out of initial letters of a longer phrase. So using "tbl" for
"table" would be an abbreviation, whereas "IO" and "PCMCIA" (and
probably GPT and GSI if I knew what they stood for) would be acronyms.
Lots of acronyms are "words" for most practical purposes, and of
course some have even made their way into standard dictionaries -
sonar, radar, and now even DSL (if I'm not mistaken). Standard
acronyms often are acceptable as "words", abbreviations almost always
not. In any case the rules for how to treat abbreviations and how
to treat acronyms should treat the two cases distinctly.
Humorous footnote - I've seen the acronym HTH at the end of countless
articles by now, but I still don't know what it means.
(And yes, I'm sure I could find a meaning online if I needed to, but
somehow it just hasn't seemed important enough yet...)
Merrill & Michele said:I have been trying for a month now to figure out what OP means, and for the
sake of language clarity, I would like to know whether it is the Original
Post or the Original Poster. The former is an 'it' while the latter has the
attribute of sex (and therefore gender). If I were not substituting a
question for an answer, I would say "Happy To Help." MPJ
^^^^^^^^Edmund Bacon said:OP Original Poster
HTH Hope this helps
HAND Have a nice day
For more info see
http://www.utdallas.edu/ir/tcs/techsupp/acronyms.htm
[...]%CC-I-ANACHRONISM, The "=-" operator is an obsolete form,
and may not be portable.
I guess many other people have been bitten by that and bitterly complained
until DEC introduced this *badly* needed warning in VAX C, otherwise the
nicest pre-ANSI C compiler I have ever used.
In <[email protected]> "Merrill & Michele"
In real world implementations, it is the value of RAND_MAX that is chosen
according to the properties of type int (among other criteria), and not
the other way round.
The standard requires both INT_MIN and RAND_MAX to be at least 32767.
However, the type of RAND_MAX need not be int, only its value must be
in the range of the type int (it is defined as an integer constant
expression).
Tim Rentsch said:Sorry, I should have made this more clear in my original writing. I
distinguish between using "abbreviations", by which I mean a
shortening of a word, and using "acronyms", by which I mean a "word"
formed out of initial letters of a longer phrase. So using "tbl" for
"table" would be an abbreviation, whereas "IO" and "PCMCIA" (and
probably GPT and GSI if I knew what they stood for) would be acronyms.
In real world implementations, it is the value of RAND_MAX that is chosen[...]
according to the properties of type int (among other criteria), and not
the other way round.
"Keith Thompson"
Agreed, with emphasis on "among other criteria". (Solaris has 32-bit
ints, but RAND_MAX==32767.)
I suppose an implementation could define RAND_MAX with a type other
than int, but I can't think of any reason to do so other than sheer
perversity. I would expect it to be an integer-constant or some
simple expression, and it has to be within the range of type int.
Keith Thompson said:There are two competing definitions for the word "acronym". One
(which I prefer and consider to be more correct) says that an acronym
is an abbreviation formed from the initial letter or letters of
several words *that is pronounced as a word*. The other doesn't
require that it be pronounced as a word. (I suppose "IO" is an
ambiguous case.)
None of which affects the main point, of course.
Merrill & Michele said:"Merrill & Michele"[...]
In real world implementations, it is the value of RAND_MAX that is chosen
according to the properties of type int (among other criteria), and not
the other way round."Keith Thompson"
Agreed, with emphasis on "among other criteria". (Solaris has 32-bit
ints, but RAND_MAX==32767.)
I suppose an implementation could define RAND_MAX with a type other
than int, but I can't think of any reason to do so other than sheer
perversity. I would expect it to be an integer-constant or some
simple expression, and it has to be within the range of type int.
It's generally not wise to snip the question and then beg it. MPJ
Keith Thompson said:Merrill & Michele said:"Merrill & Michele"[...]
In real world implementations, it is the value of RAND_MAX that is chosen
according to the properties of type int (among other criteria), and not
the other way round."Keith Thompson"
Agreed, with emphasis on "among other criteria". (Solaris has 32-bit
ints, but RAND_MAX==32767.)
The standard requires both INT_MIN and RAND_MAX to be at least 32767.
However, the type of RAND_MAX need not be int, only its value must be
in the range of the type int (it is defined as an integer constant
expression).
I suppose an implementation could define RAND_MAX with a type other
than int, but I can't think of any reason to do so other than sheer
perversity. I would expect it to be an integer-constant or some
simple expression, and it has to be within the range of type int.
It's generally not wise to snip the question and then beg it. MPJ
Um, what question did I beg?
I wasn't actually trying to answer the original question; I was
elaborating on a couple of points that Dan Pop had made.
If the question you're referring to is:
] Are you ever going to get in trouble with r declared as an int? Can
] RAND_MAX be 10^9 without forcing the implementation to make the ints wider
]as well? MPJ
I thought Dan already answered that. rand() returns a result in the
range 0 to RAND_MAX. Since the return type of rand() is int, RAND_MAX
must be representable as an int (at least 32767, and at most INT_MAX).
Keith Thompson wrote: what question did I beg?
Merrill & Michele said:There isn't a 'what" when you beg the question. I claim that you assumed
your result in order to prove it. To schloppen. MPJ
Ok, what result did I assume? (I don't believe I assumed anything.)
Tim Rentsch said:Humorous footnote - I've seen the acronym HTH at the end of countless
articles by now, but I still don't know what it means.
Richard said:Hail To Hastur - His Arrival Nears Daily.
HTH; HAND.
In said:[email protected] (Dan Pop) said:[...]%CC-I-ANACHRONISM, The "=-" operator is an obsolete form,
and may not be portable.
I guess many other people have been bitten by that and bitterly complained
until DEC introduced this *badly* needed warning in VAX C, otherwise the
nicest pre-ANSI C compiler I have ever used.
Probably so.
Strictly speaking it's an informational message ("-I-"), which is
weaker than a warning ("-W-"), which I think makes it easier to
suppress, but that shouldn't matter unless you're foolish enough to
turn off diagnostics.
The best solution for anyone still programming on VMS^H^H^H OpenVMS is
probably to use the newer DECC rather than VAXC.
In said:[lots of snippage]
Then I also don't need to declare time_t timer, correct? I just need to
include time.h (?).
I don't see how your code divides rand() into equiprobable events modulo
fam_size.
This is for the printf( %d, when it should have been printf(%ld correct?
I've got to figure something out for future posts. What I see and what I
post are radically different.
a random shift value in the range 1 .. FAMSIZ-1 and relocate each membercomputeto position (i + shift) % FAMSIZ:
shift = rand() % (FAMSIZ-1) + 1;
for (i = 0; i < FAMSIZ; i++) members = (i + shift) % FAMSIZ;
The derangement is still perfect.
So is members = members[i+1] for the the way we initialized.
The non-equiprobability of rand() % FAMSIZ is so insignificant that it is
not worth worrying about, especially considering that it is not central
to the algorithm. No reasonable family size is going to get within one
order of magnitude of the smallest allowed value for RAND_MAX. What
really matters is that rand() % FAMSIZ generates a reasonably random
value in the 0 .. FAMSIZ-1 range.
If that is not good enough for you, use your own random generator (the
rand() coming with most implementations doesn't have a particularly
good reputation) and use the algorithm described in the FAQ for
mapping it into the integer interval of your choice.
2. If the above is not possible, write your own program to replace each
TAB character by as many spaces as needed to implement TAB stops every
N characters. It is an excellent exercise for you, at your current
level.
a random shift value in the range 1 .. FAMSIZ-1 and relocate each membercomputeto position (i + shift) % FAMSIZ:
shift = rand() % (FAMSIZ-1) + 1;
for (i = 0; i < FAMSIZ; i++) members = (i + shift) % FAMSIZ;
The derangement is still perfect.
So is members = members[i+1] for the the way we initialized.
True, but the results are predictible, while my method picks one of
the FAMSIZ-1 trivial derangements at random.
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.