comp.lang.ada
 help / color / mirror / Atom feed
From: Damien Carbonne <damien.carbonne@free.fr>
Subject: GNAT GPL 2009 - issue with floating points?
Date: Fri, 09 Oct 2009 22:36:49 +0200
Date: 2009-10-09T22:36:50+02:00	[thread overview]
Message-ID: <4acf9ee2$0$23472$426a34cc@news.free.fr> (raw)

Hi,

When compiling the following sample code with GNAT GPL 2009 on Linux:

generic
    type Real is digits <>;
package Pack04 is
    Size1 : constant := Real'Size;
    Size2 : constant Integer := Real'Size;
end Pack04;

I get this:

-- pack04.ads:4:24: non-static expression used in number declaration
-- pack04.ads:4:28: size attribute is only static for scalar type (RM 
4.9(7,8))


RM 3.5(1): "scalar types comprise enumeration types, integer types, and 
real types."

RM 3.5.6 (1): "Real types provide approximations to the real numbers, 
with relative bounds on errors for floating point types, and with 
absolute bounds for fixed point types."

So Real is supposed to be a scalar!

Is this a problem with (misleading) message or with (effectively) wrong 
code?

Initially I wanted to create a generic package similar to:
generic
    type Real is digits <>;
package Generic_Float_Util is
    function Is_Positive (X : Real) return Boolean;
end Generic_Float_Util;

The intent is to get the sign of a floating point by directly reading 
the sign bit (assuming float numbers are encoded as IEEE), without any test.

Regards,

Damien



             reply	other threads:[~2009-10-09 20:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-09 20:36 Damien Carbonne [this message]
2009-10-09 21:06 ` GNAT GPL 2009 - issue with floating points? Adam Beneschan
2009-10-09 22:15   ` Damien Carbonne
2009-10-09 22:44     ` Ludovic Brenta
2009-10-10  6:33       ` Damien Carbonne
2009-10-10 14:55       ` Samuel Tardieu
2009-10-10 16:12         ` Ludovic Brenta
2009-10-10 16:38         ` Damien Carbonne
2009-10-09 23:26     ` Adam Beneschan
2009-10-10  6:39       ` Damien Carbonne
2009-10-10  7:16         ` Dmitry A. Kazakov
2009-10-11  9:33           ` Dirk Herrmann
2009-10-11 10:27             ` Dmitry A. Kazakov
2009-10-12 23:26               ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox