Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^5: rand() function on Windows systems (pure Perl)(Correction)

by BrowserUk (Patriarch)
on Jan 01, 2017 at 19:12 UTC ( [id://1178776]=note: print w/replies, xml ) Need Help??


in reply to Re^4: rand() function on Windows systems (pure Perl)
in thread rand() function on Windows systems

Hm. I forgot that Perl would upgrade the seed to a float; that needs to be clamped back to a 32-bit integer as the new line below:

{ my $seed; sub ppSrand{ $seed = int( $_[ 0 ] & 32767 ); } sub ppRand{ my $max = shift // 1; $seed = ( $seed * 214013 + 2531011 ); $seed &= 0xffffffff; return ( ( $seed >> 16 ) & 32767 ) / 32768 * $max; } }

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^6: rand() function on Windows systems (pure Perl)(Correction)
by bakiperl (Beadle) on Jan 01, 2017 at 23:09 UTC

    Great job man! This last fix cleared all my problems.

    Thank you again.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-03-28 23:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found