[perl] DUDA SOBRE NUMEROS ALEATORIOS
Salvador Ortiz Garcia
sog@msg.com.mx
Thu, 4 Mar 1999 20:16:13 -0600 (EST)
On Wed, 3 Mar 1999, JOSE MARIA MOLINA BANCALERO wrote:
> Tengo la version del perl para UNIX, y estoy intentando sacar numeros
> aleatorios entre 0 y 2, para ello pongo rand (3), pero me da como
> resultado un numero decimal entre 1 y 10, como puedo hacerlo para que me
> salga bien?.
Raro, muy raro, rand(n) _te tiene_ que dar un real en el rango (0-n].
Pero si no lo hace, es que tu perl está mal compilado:
$ perldoc -tf rand
rand EXPR
rand Returns a random fractional number greater than or equal to `0' and
less than the value of EXPR. (EXPR should be positive.) If EXPR
is omitted, the value `1' is used. Automatically calls `srand()'
unless `srand()' has already been called. See also `srand()'.
(Note: If your rand function consistently returns numbers that
are too large or too small, then your version of Perl was
probably compiled with the wrong number of RANDBITS.)
Saludos
Salvador Ortiz
--------- Pie de mensaje --------------------------------
Visite: http://tlali.iztacala.unam.mx/~randrade/perl.shtml
Cancelar inscripcion:
mail to: majordomo@tlali.iztacala.unam.mx
text : cancelacion perl