C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Standardfunktionen mit double-Parameter

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German)
View previous topic :: View next topic  
Author Message
Stefan Ram
Guest





PostPosted: Sat Sep 30, 2006 3:49 am    Post subject: Standardfunktionen mit double-Parameter Reply with quote



Eine Funktion f(double) mit einem double-Parameter kann man
grundsätzlich auch mit einem int-Argument aufrufen, wie
beisielsweise in "f(1)".

Das folgende Beispiel ist aber trotzdem fehlerhaft:

#include <iostream>
#include <ostream>
#include <cmath>
int main(){ ::std::cout << ::std::ceil( 1 )<< '\n'; }

"::std::ceil" ist nämliche mit float- und
long-double-Parametern überladen, so daß der Aufruf nun nicht
mehr auflösbar ist.

Es scheint keine Standardfunktion mit double-Parameter mehr zu
geben, die nicht auf diese Weise überladen ist. Daher kann ich
nun für Lehrzwecke kein Beispiel finden, um zu zeigen, daß man
eine Funktion mit einem double-Parameter auch mit einem
int-Wert aufrufen kann.

Es geht um eine Stelle in meinem Kurs, an der
Funktionsdefinitionen noch nicht behandelt wurden, so daß ich
nicht einfach eine Funktion dafür definieren will.

Oder kennt doch noch jemand eine Standardfunktion mit einem
double-Parameter, die man mit einem Argument vom Typ »int«
aufrufen kann?
Back to top
Marcel Müller
Guest





PostPosted: Sat Sep 30, 2006 12:31 pm    Post subject: Re: Standardfunktionen mit double-Parameter Reply with quote



Hallo,

Stefan Ram schrieb:
Quote:
int main(){ ::std::cout << ::std::ceil( 1 )<< '\n'; }

"::std::ceil" ist nämliche mit float- und
long-double-Parametern überladen, so daß der Aufruf nun nicht
mehr auflösbar ist.

Es scheint keine Standardfunktion mit double-Parameter mehr zu
geben, die nicht auf diese Weise überladen ist. Daher kann ich
nun für Lehrzwecke kein Beispiel finden, um zu zeigen, daß man
eine Funktion mit einem double-Parameter auch mit einem
int-Wert aufrufen kann.

Es gibt auch die ANSI Funktion ceilf, die explizit für float ist.


Marcel
Back to top
Stefan Ram
Guest





PostPosted: Sat Sep 30, 2006 4:38 pm    Post subject: Re: Standardfunktionen mit double-Parameter Reply with quote



Marcel Müller <news.5.maazl (AT) spamgourmet (DOT) com> writes:
Quote:
Es gibt auch die ANSI Funktion ceilf, die explizit für float ist.

Danke, aber die scheint es in C++ nicht zu geben.
Siehe auch ISO/IEC 14882:2003(E), 26.5, Table 80.
Sowie ISO/IEC 14882:2003(E), 1.1:

»C++ is a general purpose programming language
based on the C programming language as described
in ISO/IEC 9899:1990 Programming languages«
¯¯¯¯
Back to top
Rolf Magnus
Guest





PostPosted: Sat Sep 30, 2006 5:49 pm    Post subject: Re: Standardfunktionen mit double-Parameter Reply with quote

Stefan Ram wrote:

Quote:
Marcel Müller <news.5.maazl (AT) spamgourmet (DOT) com> writes:
Es gibt auch die ANSI Funktion ceilf, die explizit für float ist.

Danke, aber die scheint es in C++ nicht zu geben.
Siehe auch ISO/IEC 14882:2003(E), 26.5, Table 80.
Sowie ISO/IEC 14882:2003(E), 1.1:

»C++ is a general purpose programming language
based on the C programming language as described
in ISO/IEC 9899:1990 Programming languages«
¯¯¯¯

Es gibt da durchaus andere Meinungen dazu, soweit ich weiß aufgrund
folgender Passage:

1.2 Normative references [intro.refs]

1 The following standards contain provisions which, through reference in
this text, constitute provisions of this International Standard. At the
time of publication, the editions indicated were valid. All standards are
subject to revision, and parties to agreements based on this
International Standard are encouraged to investigate the possibility of
applying the most recent editions of the standards indicated below.
Members of IEC and ISO maintain registers of currently valid
International Standards.

[...]
— ISO/IEC 9899:1990, Programming languages – C
Back to top
Stefan Ram
Guest





PostPosted: Sat Sep 30, 2006 8:18 pm    Post subject: Re: Standardfunktionen mit double-Parameter Reply with quote

Rolf Magnus <ramagnus@t-online.de> writes:
Quote:
are encouraged to investigate the possibility of

»Dritte werden ermuntert, die Möglichkeit zu untersuchen ...«

heißt nicht, daß diese Möglichkeit damit Teil
von ISO/IEC 14882:2003(E) wird.
Back to top
Elcaro Nosille
Guest





PostPosted: Sun Oct 08, 2006 8:35 pm    Post subject: Re: Standardfunktionen mit double-Parameter Reply with quote

Quote:
Oder kennt doch noch jemand eine Standardfunktion mit einem
double-Parameter, die man mit einem Argument vom Typ »int«
aufrufen kann?

Du siehst Fallstricke wo keine sind.
Back to top
Nils Schneider
Guest





PostPosted: Fri Oct 13, 2006 11:28 pm    Post subject: Re: Standardfunktionen mit double-Parameter Reply with quote

Die Angabe "1" ist auch nicht wirklich eindeutig, besser wäre da z.b. für
int "1L", für float "1.0f" und für double "1.0"
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.