functions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sonic0568

    #1

    functions

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

    thanx!
    i am the new comer here,maybe i break some rules that i don't kown
    before;please forgive me...


  • Ingo Menger

    #2
    Re: functions


    sonic0568 schrieb:
    [color=blue]
    > what's the difference between rand() & random() ?[/color]

    om

    Comment

    • Richard Heathfield

      #3
      Re: functions

      sonic0568 said:
      [color=blue]
      > what's the difference between rand() & random() ?[/color]

      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

      email: rjh at above domain (but drop the www, obviously)

      Comment

      • Anand

        #4
        Re: functions

        sonic0568 wrote:[color=blue]
        > what's the difference between rand() & random() ?
        >
        > thanx!
        > i am the new comer here,maybe i break some rules that i don't kown
        > before;please forgive me...
        >
        >[/color]
        random() is a non-standard function, So you should see the documentation
        of your compiler.
        <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

        Comment

        • sonic0568

          #5
          Re: functions

          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~~


          Comment

          • sonic0568

            #6
            Re: functions

            Anand,thank u very much...


            Comment

            • Flash Gordon

              #7
              Re: functions

              sonic0568 wrote:[color=blue]
              > and more...richard heathfield...i respect u very much!i'm reading ur book
              > these days...it's very helpful to me![/color]

              Please don't use contractions like "u" for you and "ur" for "your". It
              makes it *much* harder to read your posts.
              [color=blue]
              > at the end,if my english has some problems,please let me kown,because my
              > mother tongue is not english..[/color]

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

              Also, please provide context when replying to a post. See

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

              Comment

              • Jordan Abel

                #8
                Re: functions

                On 2005-12-08, Flash Gordon <spam@flash-gordon.me.uk> wrote:[color=blue]
                > Poor English due to it not being your native language is not a problem.
                > Using contractions like "u" is a problem.[/color]

                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]

                Comment

                • Richard Tobin

                  #9
                  Re: functions

                  In article <slrndphena.2ma h.jmabel@random .yi.org>,
                  Jordan Abel <jmabel@purdue. edu> wrote:
                  [color=blue][color=green]
                  >> Poor English due to it not being your native language is not a problem.
                  >> Using contractions like "u" is a problem.[/color][/color]
                  [color=blue]
                  >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][/color]

                  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

                  Comment

                  • Flash Gordon

                    #10
                    Re: functions

                    Jordan Abel wrote:[color=blue]
                    > On 2005-12-08, Flash Gordon <spam@flash-gordon.me.uk> wrote:[color=green]
                    >> Poor English due to it not being your native language is not a problem.
                    >> Using contractions like "u" is a problem.[/color]
                    >
                    > 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][/color]

                    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.

                    Comment

                    • sonic0568

                      #11
                      Re: functions

                      i'll remember what you said;thank you ^ ^

                      by the way,the reason that i write that way because i'm a prince fan...he is
                      a ture genius...


                      Comment

                      • Keith Thompson

                        #12
                        Re: functions

                        "sonic0568" <sonic0568@sina .com> writes:[color=blue]
                        > i'll remember what you said;thank you ^ ^[/color]

                        One of the things he said was:

                        ] Also, please provide context when replying to a post. See
                        ] http://cfaj.freeshell.org/google/

                        Please read that web page and follow its advice.

                        --
                        Keith Thompson (The_Other_Keit h) kst-u@mib.org <http://www.ghoti.net/~kst>
                        San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
                        We must do something. This is something. Therefore, we must do this.

                        Comment

                        • Ian Malone

                          #13
                          Re: functions

                          Richard Tobin wrote:[color=blue]
                          > In article <slrndphena.2ma h.jmabel@random .yi.org>,
                          > Jordan Abel <jmabel@purdue. edu> wrote:
                          >
                          >[color=green][color=darkred]
                          >>>Poor English due to it not being your native language is not a problem.
                          >>>Using contractions like "u" is a problem.[/color][/color]
                          >
                          >[color=green]
                          >>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][/color]
                          >
                          >
                          > 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.
                          >[/color]

                          Or think. Actually, that one seems to have happened already.

                          --
                          imalone

                          Comment

                          Working...