develooper Front page | perl.perl6.users | Postings from May 2018

my keeper on random numbers

Thread Next
From:
ToddAndMargo
Date:
May 26, 2018 04:19
Subject:
my keeper on random numbers
Message ID:
fbe62a42-938d-a1e2-14df-e88d8efb763a@zoho.com
Hi All,

     This is my keep file submitted for your critique.

Many thanks,
-T


Perl 6: random numbers:

`rand` return a positive real number, always less than one:
     $ p6 'say rand;'
     0.268091668368972


Place a number in front of it to get a larger number:

     $ p6 'say 1000.rand;'
     565.2817971799526


To convert to an positive integer, use truncate:
     $ p6 'say 1000.rand.truncate;'
     876

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About