Pseudo-random numbers/Xorshift star: Difference between revisions

→‎{{header|Wren}}: nextFloat now returns a Num rather than a BigRat. Second part quicker as a result.
m (→‎{{header|Raku}}: More sensible default and constraints on seed)
(→‎{{header|Wren}}: nextFloat now returns a Num rather than a BigRat. Second part quicker as a result.)
Line 242:
{{trans|Python}}
{{libheader|Wren-big}}
As Wren doesn't have a 64-bit integer type, we use BigInt instead with BigRat for the floating point stuff.
<lang ecmascript>import "/big" for BigInt, BigRat
 
var Const = BigInt.fromBaseString("2545F4914F6CDD1D", 16)
Line 265:
}
 
nextFloat { BigRat.new(nextInt, BigInt.onetoNum <</ 2.pow(32) }
}
 
Line 274:
randomGen.seed(BigInt.new(987654321))
for (i in 1..1e5) {
var i = (randomGen.nextFloat * 5).floor.toInt
counts[i] = counts[i] + 1
}
9,479

edits