Article View: de.comp.lang.c++
Article #1606Re: pow(-1,1.1) = DOMAIN error
From: Dietmar Kuehl
Date: Thu, 22 Feb 1996 17:10
Date: Thu, 22 Feb 1996 17:10
34 lines
1832 bytes
1832 bytes
Hi,
ich werde, da es sich um eine deutsche Newsgroup handelt, einfach mal
deutsch antworten. Fuer englische Postings gibt es die analogen
englischen Newsgroups comp.lang.c++ und comp.lang.c++.moderated.
Christian Straka (Christian.Straka@uni-konstanz.de) wrote:
: The pow() and powl() function in <math.h> doesn't work properly. The following
: example causes an DOMAIN error exception (see defs in math.h):
: pow(-1,1.1);
Das Verhalten ist genau das was korrect ist ("The Standard C Library",
P.J.Plauger, Prentice Hall, p.133):
"... double pow(double x, double y);
Description:
The 'pow' function computes 'x' raised to the power 'y'. A domain error
occurs if 'x' is negative and 'y' is not an integral value. ..."
: Has anyone an idea to fix this problem?
Es ist klar, dass es nicht funktioniert, da das Ergebnis eine komplexe
Zahl ist. Damit das funktioniert, muss man schon die 'pow(...)'
Funktion mit einer komplexen Zahl bemuehen, etwa:
pow(complex<double>(-1), 1.1);
Der Typ des Rueckgabewertes aendert sich natuerlich nicht abhaengig von
den Argumenten und eine komplexe Zahl laesst sich halt nicht als
'double' darstellen.
--
dietmar.kuehl@uni-konstanz.de
http://www.informatik.uni-konstanz.de/~kuehl
I am a realistic optimist - that's why I appear to be slightly pessimistic
Technical Details
Message-ID:
<4gi82v$1qa@news.BelWue.DE>Path:
arc1-ca.pugleaf.net!news.belwue.de!uzwil!kuehlReferences:
<Christian.Straka.14.0010DFAE@uni-konstanz.de>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.belwue.de!uzwil!kuehl From: kuehl@uzwil.informatik.uni-konstanz.de (Dietmar Kuehl) Newsgroups: de.comp.lang.c++ Subject: Re: pow(-1,1.1) = DOMAIN error Date: 22 Feb 1996 17:10:55 GMT Organization: Fakultät für Mathematik und Informatik Message-ID: <4gi82v$1qa@news.BelWue.DE> References: <Christian.Straka.14.0010DFAE@uni-konstanz.de> Reply-To: dietmar.kuehl@uni-konstanz.de NNTP-Posting-Host: uzwil.informatik.uni-konstanz.de X-Newsreader: TIN [version 1.2 PL2]