Topic: domain_error


Author: MikeAlpha@NoSpam_csi.com (Martin Aupperle)
Date: Thu, 12 Apr 2001 09:42:28 GMT
Raw View
On Wed, 28 Mar 2001 19:55:45 CST, "James Kuyper Jr."
<kuyper@wizard.net> wrote:

>Frank Uepping wrote:
>>
>> John Potter wrote:
>>
>> > On Tue, 27 Mar 2001 16:33:08 CST, Frank Uepping <Frank.Uepping@epost.de>
>> > wrote:
>> >
>> > > The standard (   19.1.2) defines an exception domain_error.
>> > > What kind of errors fall in that category?
>> >
>> > sqrt(-1) is a domain_error.
>> >
>> > John
>>
>> That seems to me like an out_of_range!?
>
>Or perhaps invalid_argument. As I've said elsewhere, the standard
>doesn't distinguish these very well. In particular, since there's no
>standard-defined semantic distinctions between them, the choice is
>pretty much up to the user.
>

But these names (domain_error, out_of_range, invalid_argument) sound
as if the inventor associated some meaning with ist.  Maybe we should
ask the question what this meaning could be? E.G. what is normally
understood by "domain error"?




------------------------------------------------
Martin Aupperle
MikeAlpha@NoSpam_csi.com
(remove NoSpam_)
------------------------------------------------

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: Frank Uepping <Frank.Uepping@epost.de>
Date: Wed, 28 Mar 2001 13:08:37 CST
Raw View
John Potter wrote:

> On Tue, 27 Mar 2001 16:33:08 CST, Frank Uepping <Frank.Uepping@epost.de>
> wrote:
>
> > The standard (   19.1.2) defines an exception domain_error.
> > What kind of errors fall in that category?
>
> sqrt(-1) is a domain_error.
>
> John

That seems to me like an out_of_range!?


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: "James Kuyper Jr." <kuyper@wizard.net>
Date: Wed, 28 Mar 2001 19:55:45 CST
Raw View
Frank Uepping wrote:
>
> John Potter wrote:
>
> > On Tue, 27 Mar 2001 16:33:08 CST, Frank Uepping <Frank.Uepping@epost.de>
> > wrote:
> >
> > > The standard (   19.1.2) defines an exception domain_error.
> > > What kind of errors fall in that category?
> >
> > sqrt(-1) is a domain_error.
> >
> > John
>
> That seems to me like an out_of_range!?

Or perhaps invalid_argument. As I've said elsewhere, the standard
doesn't distinguish these very well. In particular, since there's no
standard-defined semantic distinctions between them, the choice is
pretty much up to the user.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: Barry Margolin <barmar@genuity.net>
Date: Wed, 28 Mar 2001 20:07:10 CST
Raw View
In article <3AC23602.B33CD733@epost.de>,
Frank Uepping  <Frank.Uepping@epost.de> wrote:
>John Potter wrote:
>
>> On Tue, 27 Mar 2001 16:33:08 CST, Frank Uepping <Frank.Uepping@epost.de>
>> wrote:
>>
>> > The standard (   19.1.2) defines an exception domain_error.
>> > What kind of errors fall in that category?
>>
>> sqrt(-1) is a domain_error.
>>
>> John
>
>That seems to me like an out_of_range!?

In mathematics, "domain" means the set of acceptable inputs to a function,
and "range" is the set of possible outputs.  Sqrt() is defined to accept
non-negative numbers, so a negative argument is not in the domain.

--
Barry Margolin, barmar@genuity.net
Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: "Robert W Hand" <rwhand@my-deja.com>
Date: Wed, 28 Mar 2001 20:21:36 CST
Raw View
<snip>
> >
> > > The standard (   19.1.2) defines an exception domain_error.
> > > What kind of errors fall in that category?
> >
> > sqrt(-1) is a domain_error.
> >
> > John
>
> That seems to me like an out_of_range!?
>
<snip>

I am not aware of a good definition from the C++ standard, but the C
standard clearly defines a domain error and differentiates it from an out of
range error.  Since the language of the C++ standard defines domain_error as
objects thrown as exceptions to report a domain error, I believe that using
the C standard is quite acceptable here.

It used to be taught that a function was defined on a set called its domain.
The value of the function was in a set called the range.  I believe that
different terms are sometimes used today.

So for a numerical function a domain error occurs if an input argument is
outside the domain over which the mathematical function is defined.  And a
range error occurs if the mathematical result of the function cannot be
represented in an object of the specified type, due to extreme magnitude.

So sqrt(-1) is a domain error assuming that we are interested in only the
real valued sqrt function and not the complex form.

Best wishes,

Bob


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: Frank Uepping <Frank.Uepping@epost.de>
Date: Tue, 27 Mar 2001 16:33:08 CST
Raw View
The standard (   19.1.2) defines an exception domain_error.
What kind of errors fall in that category?

Frank




---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: jpotter@falcon.lhup.edu (John Potter)
Date: Tue, 27 Mar 2001 19:03:49 CST
Raw View
On Tue, 27 Mar 2001 16:33:08 CST, Frank Uepping <Frank.Uepping@epost.de>
wrote:

> The standard (   19.1.2) defines an exception domain_error.
> What kind of errors fall in that category?

sqrt(-1) is a domain_error.

John

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]