Skip to content

Commit 4fbbb84

Browse files
committed
Update js-compute-builtins.cpp
1 parent 4445618 commit 4fbbb84

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

c-dependencies/js-compute-runtime/js-compute-builtins.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4404,11 +4404,10 @@ bool process_network_io(JSContext *cx) {
44044404
}
44054405

44064406
bool math_random(JSContext *cx, unsigned argc, Value *vp) {
4407-
int32_t storage;
4408-
int32_t *buf = &storage;
4409-
random_get((int32_t)buf, sizeof(storage));
4410-
uint32_t value = storage + std::pow(2, 32);
4411-
double newvalue = static_cast<float>(value) / std::powf(2.0, 32.0);
4407+
unt32_t storage;
4408+
unt32_t *buf = &storage;
4409+
random_get((int32_t)(&buf), sizeof(storage));
4410+
double newvalue = static_cast<double>(storage) / std::pow(2.0, 32.0);
44124411

44134412
CallArgs args = CallArgsFromVp(argc, vp);
44144413
args.rval().setDouble(newvalue);

0 commit comments

Comments
 (0)