We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5437642 commit 8151b28Copy full SHA for 8151b28
compiler/natives/src/net/fastrand.go
@@ -7,5 +7,5 @@ import (
7
_ "unsafe" // For go:linkname
8
)
9
10
-//go:linkname fastrand runtime.fastrand
11
-func fastrand() uint32
+//go:linkname fastrandu runtime.fastrandu
+func fastrandu() uint
compiler/natives/src/runtime/fastrand.go
@@ -13,3 +13,15 @@ func fastrand() uint32 {
13
// similar distribution.
14
return uint32(js.Global.Get("Math").Call("random").Float() * (1<<32 - 1))
15
}
16
+
17
+func fastrandn(n uint32) uint32 {
18
+ return fastrand() % n
19
+}
20
21
+func fastrand64() uint64 {
22
+ return uint64(fastrand())<<32 | uint64(fastrand())
23
24
25
+func fastrandu() uint {
26
+ return uint(fastrand())
27
0 commit comments