 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Aurélien Barbier-Accary Guest
|
Posted: Sat Oct 08, 2005 7:17 am Post subject: +- infini |
|
|
Bonjour,
j'ai besoin de définir la classe suivante :
class ScalaireBorné // sans accent bien sûr
{
protected:
double xmin, x, xmax; // xmin <= x <= xmax
public:
ScalaireBorne(const double& x, const double& xmin=???, const double& xmax=???);
//...
};
Ma question est donc comment donner les bornes par défaut -inf et +inf ?
Il me semble que ces bornes sont 2^-1075 et 2^1024 mais comment les définir
proprement ?
Existe-t-il une bibliothèque qui les défini où faut-il utiliser quelque chose du
type 1>>1075 et 1<<1024 ?
Je sais que gcc (que j'utilise) déclare des fonctions isNaN(), isinf() et
finite(), mais je n'ai rien trouvé pour les valeurs -inf et +inf :-(
Aurélien.
|
|
| Back to top |
|
 |
Arnaud Debaene Guest
|
Posted: Sat Oct 08, 2005 8:30 am Post subject: Re: +- infini |
|
|
Aurélien Barbier-Accary wrote:
| Quote: | Bonjour,
j'ai besoin de définir la classe suivante :
class ScalaireBorné // sans accent bien sûr
{
protected:
double xmin, x, xmax; // xmin <= x <= xmax
public:
ScalaireBorne(const double& x, const double& xmin=???, const
double& xmax=???); //...
};
Ma question est donc comment donner les bornes par défaut -inf et
+inf ?
|
std::numeric_limits
Arnaud
|
|
| Back to top |
|
 |
Aurélien Barbier-Accary Guest
|
Posted: Sat Oct 08, 2005 10:19 am Post subject: Re: +- infini |
|
|
Arnaud Debaene a écrit :
| Quote: | Aurélien Barbier-Accary wrote:
Ma question est donc comment donner les bornes par défaut -inf et +inf ?
std::numeric_limits<double>::infinity()
Arnaud
nickel, merci ! |
Finalement j'utilise donc numeric_limits<double>::min() et
numeric_limits<double>::max().
Aurélien.
|
|
| Back to top |
|
 |
|
|
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
|
|