Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Re: Random numbers generation

by pizza_milkshake (Monk)
on May 21, 2004 at 16:58 UTC ( [id://355347]=note: print w/replies, xml ) Need Help??


in reply to Re: Random numbers generation
in thread Random numbers generation

this will generate numbers between 250 and 499 because of the behaviors of rand and int:

rand Returns a random fractional number greater than or equal to 0 and less than the value of EXPR.

int Returns the integer portion of EXPR. If EXPR is omitted, uses $_. You should not use this function for rounding: one because it trun-cates towards 0, and two because machine representations of floating point numbers can sometimes produce counterintuitive results.

rand(250) will always return a number less than 250 and int will never round up.

use rand(251)

perl -e"\$_=qq/nwdd\x7F^n\x7Flm{{llql0}qs\x14/;s/./chr(ord$&^30)/ge;print"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://355347]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-19 21:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found