Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re2 (rand() in C): A little C code converted to Perl *HELP*

by bbfu (Curate)
on Nov 03, 2003 at 17:54 UTC ( #304190=note: print w/replies, xml ) Need Help??

in reply to Re: A little C code converted to Perl *HELP*
in thread A little C code converted to Perl *HELP*

The rand function in C returns a random integer. The OP's C code seems to assume 16 bit integers, so that's a max of 65535 (or 32767 to -32768, IIRC). So, I think the equivalent Perl code would be something like:

$gcheck = sprintf "%x", ((int(rand(65536)) << 16) | int(rand(65536)));

Black flowers blossom
Fearless on my breath

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://304190]
[james28909]: but then you have the others as well
[Lady_Aleena]: Renaming things like get_THAC0 to just THAC0 was easy. These are harder.
[james28909]: consolidate the three subs into one
[Lady_Aleena]: Um, what?
[james28909]: check is is data or hash or array and do tasks then return needed data
[Lady_Aleena]: james28909, you might want to look at the other two on my scratchpad.

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2017-05-24 04:48 GMT
Find Nodes?
    Voting Booth?