c++11 random: why different range of int and real?

In the c++11, we now have <random> to produce random number. About uniform distributions, we have following int_distribution and double_distribution:

uniform_int_distribution-produces integer values evenly distributed across a range

uniform_real_distribution-produces real values evenly distributed across a range

The first produces random integer values i, uniformly distributed on the closed interval [a, b], but the second, ie real one, produces random floating-point values i, uniformly distributed on the interval [a, b)

Question: why int and real distribution have different range, ie for one b] is inclusive but for another b) is exclusive?

If it is related with the algorithms behind, I would like to know what are they and where are the differences. Or preferences about it.

• Related reading: Random in C++11 with closed interval. – user22815 Feb 19 '15 at 13:48
• I cannot answer definitely, but consider the range 0..1. With integers, an open range would always return 0. With floating point, it cannot return 1, but there are a very large number of values it can return. If you need different behavior, you are free to define your own distribution object. – user22815 Feb 19 '15 at 13:55
• For int distributions there's two use cases: either you care about the number of values but not the range (e.g. for simulating probabilistic events) or you do care about the range. For the former an open interval is more useful because it's easier to calculate the number of values (max - min). For the latter case you already know the min and max you want to get so the inclusive format is easier. It seems they're catering to the latter use case. I'm not sure what's the rationale behind excluding the maximum in the real distribution though. – Doval Feb 19 '15 at 14:43