Questions tagged [drand48]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
202 views

Understanding the generate.c function

I am trying to understand this code from the generate.c program: for (int i = 0; i < n; i++) { printf("%i\n", (int) (drand48() * LIMIT)); } I see that the drand48 function returns a ...
0
votes
1answer
338 views

Does (drand48() * LIMIT) generates random numbers upto LIMIT?

(drand48() * LIMIT) Does the above code in 'generate.c' file of pset3 mean that drand48 generates random numbers upto the value defined in LIMIT? E.g - #define LIMITS 234 drand48()*LIMITS In ...
1
vote
2answers
540 views

Best solution to move the ball in Breakout?

What's the best solution for providing proper parameters (x,y) for move() function? "Move() function" we use it to move the ball in the Breakout game.
0
votes
1answer
3k views

implicit declaration of function 'drand48()' is invalid in c99 / generating random numbers

I'm now working on pset4 in edx. The spec requires that the velocity of the ball to be generated from a random number using drand48(). I looked at man drand48() saying this is a double type stuff, ...
0
votes
2answers
344 views

pset4 velocity & ball's angle

I'm stuck in step 6. I have understood how to make the ball bounce on the window's edges but I cannot figure out how to make the ball move in an angle. I assume that it has to be some combination of Y-...
0
votes
1answer
160 views

drand48() Invalid Operands

This is my code: int min = 6; int max = 9; double x = min + (drand48() * 10) % (max - (min - 1)); Console Error message: Any idea what I am doing wrong?