10 Mar
2015
10 Mar
'15
11:37 a.m.
there's no nearest rational number, as there are inifinetly many of them in any bounded neighbourhood of any real number. Unless by nearest you mean the nearest rational with the greatest representable denominator... but in this case the result will not be uniform anymore. As said, uniformity ( meaning prob(x in [a,b])=b-a ) seems fundamentally impossible for rationals for the aforementioned reasons ...
That not withstanding, the conversion from floating point to rational is *exact*. So floating point values in the range [1/INT_MAX, INT_MAX] would map exactly to rational values in that range. Whether they have the distribution you want is another matter. John.