Almost correct :) You need to add start to the return value:
use 5.14.2; use warnings; use Inline "C"; say for getRand (50, 1000, 10); __END__ __C__ #include <stdlib.h> void getRand (int start, int end, int iterations) { time_t t; srand ((unsigned)time (&t)); inline_stack_vars; inline_stack_reset; int i; for (i = 0; i < iterations; i++) { int randomNum = rand () % (end - start); inline_stack_push (sv_2mortal (newSViv (start + randomNum))); +/* Add start to random number */ } inline_stack_done; }
In reply to Re^2: Make random numbers
by Tux
in thread Make random numbers
by GHMON
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |