Help me understand this code...

This is a discussion on Help me understand this code... within the C Programming forums, part of the General Programming Boards category; I want to make sure i understand what the following code is doing: Code: #include <math.h> float expdev(long *idum) { ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    1

    Help me understand this code...

    I want to make sure i understand what the following code is doing:
    Code:
    #include <math.h>
         float expdev(long *idum) {
                   float ran0(long *idum);
                   float dummy;
                   do
                       dummy=ran0(idum);
                  while (dummy == 0.0);
                 return -log(dummy);
    }
    So when someone calls on expdev, passing in idum, the value of idum is changed via ran0 correct? so if idum is 3 to start out with and runs once, the 2nd run of this function will have a different idum value right?

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    ran0 can change the value pointed to by idum, yes; whether it does or not, who knows.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 03:17 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 05:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21