Ancestors

Toot

Written by John Hawthorn on 2024-08-29 at 17:38

def really_rand = [rand(2**64)].pack("Q").unpack1("D")
really_rand()

=> 2.0251516865267015e+83

really_rand()

=> -1.0005918537287168e-151

=> More informations about this toot | More toots from john@hawthorn.pub

Descendants

Written by Alex on 2024-08-29 at 17:42

@john cursed crypto. can you explain what’s going on there?

=> More informations about this toot | More toots from akahn@mastodon.social

Written by John Hawthorn on 2024-08-29 at 18:22

@akahn For testing I needed to generate random floating point numbers from -infinity to infinity (rand() just gives 0.0 to 1.0). This generates random 64 bit integers and then reinterprets their bytes as a double.

=> More informations about this toot | More toots from john@hawthorn.pub

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113046529201103282
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
269.682758 milliseconds
Gemini-to-HTML Time
0.812427 milliseconds

This content has been proxied by September (3851b).