V
V
Vadusik2015-10-27 02:32:58
PHP
Vadusik, 2015-10-27 02:32:58

What function can produce random values ​​from 0 to 1 of different lengths?

There is a pseudo-random sequence of numbers, all are fractions of 1. After the point in most cases there are 14 digits, but sometimes there are 15 or vice versa 13 digits. I don't see any dependency, except that numbers that start with 0.0... usually have 15 digits after the decimal point.
What randomization function or several functions can result in these numbers?
I'm sure that the respected public knows what the numbers look like (author's note - LOL), but still here are examples:
0.14812561761131
0.057436987123556

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stanislav Makarov, 2015-10-27
@Nipheris

0.14812561761131
0.057436987123556

0.14812561761131 0
0.05743698712355 6
Not?
What's stopping you from generating an integer and dividing it by INT_MAX? or the maximum number that can be generated? Just get the interval [0; one)

S
SeptiM, 2015-10-27
@SeptiM

I agree with the previous answer. The length may simply depend on rounding. What do you want to end up with? It is impossible to understand which generator is based on two samples. You can't even guess the distribution here.

K
Konstantin   , 2016-09-26
@SynCap

There is only one available in Javascript - Math.random() , everything else random and pseudo-random in Javascript still revolves around it.
If you need a random number of a certain length, it's easier to create it artificially.
Random number with 3 decimal places:
or like this:
Math.random().toString().slice(0, 2 + 3 )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question