Range syntax

N

newbarker

I'm looking through the C++ standard and see statements like this:

yields: the smallest q in
[p,p+n) such that
X::eq(*q,c) is true, zero
otherwise.

I'm not from a scientific/math background but would like to read more
about what this "[p,p+n)" syntax is called and how it's defined so
does anyone have a link to a web page about this please?

Regards,

Pete
 
J

Juha Nieminen

I'm not from a scientific/math background but would like to read more
about what this "[p,p+n)" syntax is called and how it's defined so
does anyone have a link to a web page about this please?

The notation of ranges is rather simple: Square brackets are used when
the extreme values are included in the range, and parentheses when they
are excluded. They can also be mixed, as in your example.

"[p, p+n)" means a range of values between p and p+n, including p but
excluding p+n.

In theory you could also have (p, p+n] which would mean a range of
values between p and p+n, excluding p but including p+n. Of course this
is seldom used when talking about C++.
 
J

James Kanze

I'm looking through the C++ standard and see statements like this:
yields: the smallest q in
[p,p+n) such that
X::eq(*q,c) is true, zero
otherwise.
I'm not from a scientific/math background but would like to
read more about what this "[p,p+n)" syntax is called and how
it's defined so does anyone have a link to a web page about
this please?

Victor and Juha have already given the details, but it's worth
mentionning that this is called a half open interval---an
interval which includes its end points is closed, one which
doesn't is open. Also, the notation varies: "[a,b)" (or
"[a...b)") is almost universal in the anglo-saxon world, but in
France, I've often seen "[a;b[" or "[a...b[", with the [] being
used backwards to indicate openness. (Note too the use of ';'
instead of ','. This is usual in much of the world, where the
decimal character is a comma, and not a point.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,919
Members
47,458
Latest member
Chris#

Latest Threads

Top