On Apr 18, 5:20 am, Martin Rennix <martin.ren...@gmail.com> wrote:
> On Apr 18, 8:41 am, Ron Natalie <r...@spamcop.net> wrote:
> > MartinRennixwrote:
> > > Eg
> > > class Foo
> > > {
> > > static const float f = 0.0f; // error
> > > static const int i = 0; // ok
> > > };
> > > What's the reasoning behind this seemingly arbitrary limitation?
> > The compiler is only required to know how to do integer math at compile
> > time.
Also, the fact that there is no need for it. It's really a
hack, which was added for integers is because certain uses
require an integral constant expression.
> Is that because in the "olden days" you couldn't guarantee that a FPU
> would be available, or the equivalent software floating point library?
It's because even today, cross-compilers exist, and floating
point results depend on the actual floating point being used.
Something like 2. * 3.14 will have different values on different
machines. And the standard doesn't impose emulation of the
target floating point hardware.
--
James Kanze (GABI Software) email:
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
|