SFML community forums

General => General discussions => Topic started by: auriplane on November 16, 2009, 08:56:17 pm

Title: Doc suggestion: State that sf::Randomizer is inclusive
Post by: auriplane on November 16, 2009, 08:56:17 pm
Hi,

This is minor.

To me it wasn't obvious whether Randomizer's range was inclusive of Begin and End, from reading the docs.  I intuitively expected it to be a half-open range, like in STL, so I expected it to include Begin and not End.

Since I didn't see it anywhere, I wrote a quick test program, and discovered that it is an open range and includes End.  If you could put that into the docs, it could save a bit of confusion with people and off-by-one errors down the road :-)
Title: Doc suggestion: State that sf::Randomizer is inclusive
Post by: Hiura on November 16, 2009, 09:19:28 pm
There're some mistakes in your words ( it's very subtle ) :

Terminology

An open interval does not include its endpoints, and is indicated with parentheses. For example (0,1) means greater than 0 and less than 1. Conversely, a closed interval includes its endpoints, and is denoted with square brackets. For example [0,1] means greater than or equal to 0 and less than or equal to 1.
Title: Doc suggestion: State that sf::Randomizer is inclusive
Post by: Laurent on November 16, 2009, 09:21:58 pm
The doc says "in the range [begin, end]". Isn't it clear? :)
Title: Doc suggestion: State that sf::Randomizer is inclusive
Post by: auriplane on November 16, 2009, 09:45:09 pm
Oops.  I said open when I said closed, and vice versa?  Ah, it's been a while :-)

Thanks for your replies!  I see the [Begin, End] now.  I must have been looking at the summary "Get a random integer number in a given range." and/or the Tutorial, and not actually looked at the function documentation.  Or so I guess!