As mt1022 suggested, the reason is in the runif source of C :
double runif(double a, double b) { if (!R_FINITE(a) || !R_FINITE(b) || b < a) ML_ERR_return_NAN; if (a == b) return a; else { double u; do {u = unif_rand();} while (u <= 0 || u >= 1); return a + (b - a) * u; } }
In the return argument, you can see the formula a + (b - a) * u which uniformly generates [0, 1] a random value in the user-provided interval [a, b]. In your case it will be -M + (M + M) * u . Thus, M + M if 1.79E308 + 1.79E308 generates Inf . Those. finite + Inf * finite = Inf :
M + (M - m) * runif(1, 0, 1)
Artem source share