fix random()

This commit is contained in:
2025-12-14 13:30:46 -06:00
parent b98cef6e8d
commit 169448f156

View File

@@ -279,8 +279,9 @@ var HEADER = Symbol()
// returns a number between 0 and 1. There is a 50% chance that the result is less than 0.5. // returns a number between 0 and 1. There is a 50% chance that the result is less than 0.5.
$_.random = function() { $_.random = function() {
var n = os.random() // os.random() returns a 53-bit integer (uint64 >> 11)
return n > 100000 // Divide by 2^53 to get a value in [0, 1)
return (os.random() / 9007199254740992)
} }
$_.random_fit = os.random $_.random_fit = os.random