Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Doc suggestion: State that sf::Randomizer is inclusive  (Read 3392 times)

0 Members and 1 Guest are viewing this topic.

auriplane

  • Newbie
  • *
  • Posts: 6
    • MSN Messenger - crystal@panix.com
    • AOL Instant Messenger - auriplane
    • Yahoo Instant Messenger - auriplane
    • View Profile
    • http://www.xtalcy.com/
Doc suggestion: State that sf::Randomizer is inclusive
« 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 :-)

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Doc suggestion: State that sf::Randomizer is inclusive
« Reply #1 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.
SFML / OS X developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Doc suggestion: State that sf::Randomizer is inclusive
« Reply #2 on: November 16, 2009, 09:21:58 pm »
The doc says "in the range [begin, end]". Isn't it clear? :)
Laurent Gomila - SFML developer

auriplane

  • Newbie
  • *
  • Posts: 6
    • MSN Messenger - crystal@panix.com
    • AOL Instant Messenger - auriplane
    • Yahoo Instant Messenger - auriplane
    • View Profile
    • http://www.xtalcy.com/
Doc suggestion: State that sf::Randomizer is inclusive
« Reply #3 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!

 

anything