There's a lot of kludges in this code. Some of the more obvious ones:'
(1) The rng function returns a double, but it can only return a bit over two million diferent values, wasting half the precison of a typical double.
(2) then it multiplies the 0..1 value by the wrong scale factor. To get a number between one and x you want to multiply the 0..1 rng by (x-1), not (x+0.99).
(3) Then since the result can be somewhat out of range, there's the kludge of dividing by ten if it's too big.
(4) And also the strange business of scaling up results under 0.01.
Just plain badly thought out code, then badly patched to boot.