MCPcopy Create free account
hub / github.com/nodejs/node / rand_int

Function rand_int

test/fixtures/wpt/common/utils.js:77–89  ·  view source on GitHub ↗

@private

(bits)

Source from the content-addressed store, hash-verified

75
76/** @private */
77function rand_int(bits) {
78 if (bits < 1 || bits > 53) {
79 throw new TypeError();
80 } else {
81 if (bits >= 1 && bits <= 30) {
82 return 0 | ((1 << bits) * Math.random());
83 } else {
84 var high = (0 | ((1 << (bits - 30)) * Math.random())) * (1 << 30);
85 var low = 0 | ((1 << 30) * Math.random());
86 return high + low;
87 }
88 }
89}
90
91/** @private */
92function to_hex(x, length) {

Callers 1

tokenFunction · 0.85

Calls 1

randomMethod · 0.80

Tested by

no test coverage detected