🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: de.comp.lang.c++
3 messages
3 total messages Started by Christian Straka Thu, 22 Feb 1996 16:52
pow(-1,1.1) = DOMAIN error
#1605
Author: Christian Straka
Date: Thu, 22 Feb 1996 16:52
10 lines
687 bytes
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);

Has anyone an idea to fix this problem?

Christian

e-mail: Christian.Straka@uni-konstanz.de
Re: pow(-1,1.1) = DOMAIN error
#1606
Author: Dietmar Kuehl
Date: Thu, 22 Feb 1996 17:10
34 lines
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
Re: pow(-1,1.1) = DOMAIN error
#1608
Author: Kurt Watzka
Date: Thu, 22 Feb 1996 18:35
36 lines
1683 bytes
Christian.Straka@uni-konstanz.de (Christian Straka) writes:

>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);

>Has anyone an idea to fix this problem?

Ich werde versuchen, meine Deutschkenntinisse anzuwenden, weil sowohl
der Fragesteller als auch die meisten Leser vermutlich Deutsch koennen.

1.) Was ist (-1)^(1.1)? 

    Naeherungsweise ist das Ergebnis -0.9519565 - 0.309017 i, also 
    eben keine reele Zahl. Die Funktionen der Fliesskommabibliothek
    sind aber nur fuer _reele_ Arithmetik gedacht. 

2.) Was ist eine moegliche Loesung?

    Der Header <complex> kann die benoetigte Funktion enthalten.

    Nach dem aktuellen Draft Working Paper ist eine Funktion

       template <class T> 
       complex<T> pow(const complex<T> &, const complex<T> &);

    vorgesehen. Soweit ein Entwicklungssystem dem Standard in dieser
    Hinsicht bereits folgt, sollte der Aufruf von pow() mit Parametern
    von geeignetem Typ das gewuenschte (?) Ergebnis liefern.

Kurt
--
| Kurt Watzka                             Phone : +49-89-2180-6254
| watzka@stat.uni-muenchen.de
| ua302aa@sunmail.lrz-muenchen.de
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads