From -7294935280017716058
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,13991629fd9cd1db
X-Google-Attributes: gidf78e5,public
From: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: <float.h> [was Re: Exploding integers]
Date: 1997/01/21
Message-ID: <5c182m$2o5@mulga.cs.mu.OZ.AU>#1/1
X-Deja-AN: 211407745
references: <32DDD024.CEE@mds.rmit.edu.au> <5bo4qs$djf@lyra.csx.cam.ac.uk> <5boke5$r82@mpscomm.usin.com> <9701172338.aa27862@SMOKEY.ARL.MIL> <5bu8us$1f1@lyra.csx.cam.ac.uk> <32E2C09E.41C6@wizard.net> <5c0ptt$i8m@lyra.csx.cam.ac.uk>
x-original-date: 21 Jan 1997 02:01:58 GMT
organization: Comp Sci, University of Melbourne
x-auth: PGPMoose V1.1 PGP comp.std.c++
newsgroups: comp.std.c++
originator: austern@isolde.mti.sgi.com


nmm1@cus.cam.ac.uk (Nick Maclaren) writes:

>James Kuyper <kuyper@wizard.net> writes:
>|> Nick Maclaren wrote:
>|> ...
>|> > I don't suppose that there is any chance of fixing <float.h>?  And I DO
>|> > mean "fixing" - the current one is of little use except for checking
>|> > that your own version corresponds with the compiler's idea of reality.
>|> ...
>|> Could you expand on that? What doesn't it do right?
>
>Except for FLT_RADIX, none of the the values are required to be
>constant expressions.

This problem is at least partially fixed in the C++ numeric_limits template.
The draft C++ standard specifies the following:

 |   18.2.1  Numeric limits                                    [lib.limits]
 | 
 | 3 For  all members declared static const in the numeric_limits template,
 |   specializations shall define these values in such a way that they  are
 |   usable as integral constant expressions.

All members of numeric_limits that have an integral type are specified
as static const, so they must be integral constant expressions.

However, the members of numeric_limits<float> which are functions that
return float, namely min(), max(), epsilon(), round_error(),
infinity(), quiet_NaN(), signaling_NaN(), and denorm_min(),
are not constant expressions.  Still, in C++ it's probably not
so important, since in C++ the initializer for a global const
doesn't have to be a constant expression.

 |   18.2.1.1  Template class numeric_limits           [lib.numeric.limits]
 |   namespace std {
 |     template<class T> class numeric_limits {
 |     public:
 |       static const bool is_specialized = false;
 |       static T min() throw();
 |       static T max() throw();
 |       static const int  digits = 0;
 |       static const int  digits10 = 0;
 |       static const bool is_signed = false;
 |       static const bool is_integer = false;
 |       static const bool is_exact = false;
 |       static const int  radix = 0;
 |       static T epsilon() throw();
 |       static T round_error() throw();
 | 
 |       static const int  min_exponent = 0;
 |       static const int  min_exponent10 = 0;
 |       static const int  max_exponent = 0;
 |       static const int  max_exponent10 = 0;
 | 
 |       static const bool has_infinity = false;
 |       static const bool has_quiet_NaN = false;
 |       static const bool has_signaling_NaN = false;
 |       static const bool has_denorm = false;
 |       static const bool has_denorm_loss = false;
 |       static T infinity() throw();
 |       static T quiet_NaN() throw();
 |       static T signaling_NaN() throw();
 |       static T denorm_min() throw();
 | 
 |       static const bool is_iec559 = false;
 |       static const bool is_bounded = false;
 |       static const bool is_modulo = false;
 | 
 |       static const bool traps = false;
 |       static const bool tinyness_before = false;
 |       static const float_round_style round_style = round_toward_zero;
 |     };
 |   }

--
Fergus Henderson <fjh@cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh@128.250.37.3         |     -- the last words of T. S. Garp.
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]



