Velocity Reviews > functions

functions

sonic0568
Guest
Posts: n/a

 12-08-2005
what's the difference between rand() & random() ?

thanx!
i am the new comer here,maybe i break some rules that i don't kown

Ingo Menger
Guest
Posts: n/a

 12-08-2005

sonic0568 schrieb:

> what's the difference between rand() & random() ?

om

Richard Heathfield
Guest
Posts: n/a

 12-08-2005
sonic0568 said:

> what's the difference between rand() & random() ?

rand() is a standard C library function, prototyped in the <stdlib.h>
header. It produces, on successive calls, a series of pseudo-random numbers
in the range 0 to RAND_MAX. You can set the starting point in that series
by passing it to srand(), which is also a standard library function.

random() is whatever you want it to be, subject only to your skill and
imagination. Implementations are free to provide extra functions as an
extension if they wish, and they have to call them something, so you might
want to have a look at your documentation to see whether random() is
mentioned there. If it is, bear in mind that some other implementation
might implement that function with different functionality, or not
implement it at all.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)

Anand
Guest
Posts: n/a

 12-08-2005
sonic0568 wrote:
> what's the difference between rand() & random() ?
>
> thanx!
> i am the new comer here,maybe i break some rules that i don't kown
>
>

random() is a non-standard function, So you should see the documentation
<OT>
My compiler has the following doc.
| The random() and srandom() functions have (almost) the same
| calling sequence and initialization properties as rand() and
| srand() (see rand(3C)). The difference is that rand(3C) pro-
| duces a much less random sequence-in fact, the low dozen
| bits generated by rand go through a cyclic pattern. All the
| bits generated by random() are usable.
</OT>
For more details about rand() and generating a random number, see the FAQ.

--
(Welcome) http://www.ungerhu.com/jxh/clc.welcome.txt
(clc FAQ) http://www.eskimo.com/~scs/C-faq/top.html

sonic0568
Guest
Posts: n/a

 12-08-2005
and more...richard heathfield...i respect u very much!i'm reading ur book
these days...it's very helpful to me!

at the end,if my english has some problems,please let me kown,because my
mother tongue is not english..

thank u veeeeerrrry much~~

sonic0568
Guest
Posts: n/a

 12-08-2005
Anand,thank u very much...

Flash Gordon
Guest
Posts: n/a

 12-08-2005
sonic0568 wrote:
> and more...richard heathfield...i respect u very much!i'm reading ur book
> these days...it's very helpful to me!

Please don't use contractions like "u" for you and "ur" for "your". It

> at the end,if my english has some problems,please let me kown,because my
> mother tongue is not english..

Poor English due to it not being your native language is not a problem.
Using contractions like "u" is a problem.

--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.

Jordan Abel
Guest
Posts: n/a

 12-08-2005
On 2005-12-08, Flash Gordon <(E-Mail Removed)> wrote:
> Poor English due to it not being your native language is not a problem.
> Using contractions like "u" is a problem.

At least, until it becomes standard english it is. Expect this in a
couple centuries at most, less if you stop fighting it [but it is
inevitable]

Flash Gordon
Guest
Posts: n/a

 12-08-2005
Jordan Abel wrote:
> On 2005-12-08, Flash Gordon <(E-Mail Removed)> wrote:
>> Poor English due to it not being your native language is not a problem.
>> Using contractions like "u" is a problem.

>
> At least, until it becomes standard english it is. Expect this in a
> couple centuries at most, less if you stop fighting it [but it is
> inevitable]

1) It is not inevitable that it will become standard English.
2) I was stating the plain and simple truth when I said it is a problem.
It takes me noticeably more effort and time to read a post using
those contractions, and others have said the same in the past so it
is not just me.
--
Flash Gordon,
Dyslexic Software Developer,
At least the compiler ensures I spell variable names consistently wrong.

Richard Tobin
Guest
Posts: n/a

 12-08-2005
In article <(E-Mail Removed)>,
Jordan Abel <(E-Mail Removed)> wrote:

>> Poor English due to it not being your native language is not a problem.
>> Using contractions like "u" is a problem.

>At least, until it becomes standard english it is. Expect this in a
>couple centuries at most, less if you stop fighting it [but it is
>inevitable]

Do you really think that most people will still be typing text in 200
years time? I think it's quite likely that most people will not need
to be able to read or write long before that.

-- Richard