In the specific case that you are showing, it looks like the numbers are generated using the following naive algorithm, starting with x = .1 .
- Multiply
x by 3. - Extract the integer and fractional parts of the result.
- Print the integer part as a digit and replace
x with the fractional part. - Repeat steps 1 through 3 until they become boring (or until a specific preset is reached).
This will work fine mathematically, but in a floating-point world, this is certainly completely nonsense, since multiplying by 3 and then rounding to the nearest floating-point number potentially leads to a small error, and after 30 digits, or thus, the error completely fills the original numbers, and we just get the trash.
Presumably there is a way to process the numbers before the point for the case when the initial number is greater than 1.0 in absolute value, but without sample output, I'm not going to guess what kind of algorithm it is.
To justify the above, here is some code in Python whose output exactly matches the one asked in the question. Here modf is an operation that extracts the fractional and integral parts of floating Python.
>>> from math import modf >>> x = 0.1 >>> digits = [] >>> for _ in xrange(1099): ... x, digit = modf(3.0 * x) ... digits.append(str(int(digit))) ... >>> print('0.' + ''.join(digits))
And the conclusion:
0, 01100021211101012101011202020110010112202201201001020212002021112020021121202000000222122210022012001201
This should answer one of your questions: namely, where the random numbers come from. I can't answer the question of why Chrome selects so many numbers.
source share