Should uniform(-real.max, real.max) be inf?

Magnus Lie Hetland magnus at hetland.org
Fri Mar 2 00:25:15 PST 2012


On 2012-03-01 16:34:23 +0000, Ali Çehreli said:

> Since there are also sub-normal values between 0 and T.min_normal, it 
> may make sense to use the range [T.min_normal, 1) and scale the result 
> from there. But I haven't tested whether the distinct values in that 
> range are equally distributed.

I get similar results now that I did when I started with the range from 
-1 to 1, but I'm guessing it's my brain that's a little slow. I was 
perplexed that (for float) almost all the numbers had an exponent of 
38, while only a few had 37, and none had anything else (in my limited 
tests).

Buuuut that's just the problem with (at least my) "common sense" and 
exponentials/logarithms. There are, of course, ten times as many 
numbers with an exponent of 38 as there are with an exponent of 37 (and 
so on, down the line; c.f., the incompressibility lemma etc.).

For testing, I might want some small numbers, too -- perhaps I should 
just generate the mantissa and exponent separately (maybe even throwing 
in some NaNs and Infs etc.) :)

Thanks for your help, though.

-- 
Magnus Lie Hetland
http://hetland.org



More information about the Digitalmars-d-learn mailing list