H
H
Heretic Man2018-12-15 21:55:55
JavaScript
Heretic Man, 2018-12-15 21:55:55

How does the creation of a random number by the Math.random() method occur at the native level, I want to understand the meaning - how?

It may be worth setTimeout + addition with something else ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman, 2018-12-15
@heretic_man

using an implementation-dependent algorithm or strategy

https://tc39.github.io/ecma262/#sec-math.random
In V8, for example, the implementation is like this https://github.com/v8/v8/blob/master/src/math-random.cc
Use xorshift128+
Details https ://hackernoon.com/how-does-javascripts-math-r...
dude with a sense of humor)))
If you're like me (with a front-end background and no CS degree) you look at this and think “Ok, variable assignment, variable assignment, function… simple enough…” but then you come to s1 ^= s1 << 23; and say “what the shit?”

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question