From: hebisch@math.uni.wroc.pl (Waldek Hebisch)
Subject: Is this a gnat bug?
Date: 20 Sep 2003 22:50:11 GMT
Date: 2003-09-20T22:50:11+00:00 [thread overview]
Message-ID: <bkilj3$kl5$1@panorama.wcss.wroc.pl> (raw)
I am trying to convert a sequence of eight bytes to a fixed point
number. For testing I put bytes in an array. I first collect bytes
in a modular type and then assign the result to an integer (I have
eight bytes in big endian order, but the actual number should be
small). When number formed from 4 lower order bytes is out of
range I get CONSTRAINT_ERROR but if only higher order bytes are
non-zero I get just zero result. I would expect CONSTRAINT_ERROR
always when any of higher order bytes is non-zero. With both
gnat-3.14p and gnat from gcc-3.3 the program below prints huge
number for 'pp' and 0.0 for 'price'.
with Ada.Text_IO;
procedure tstnum is
type fx15_2 is delta 0.01 range -9999999999999.99 .. 9999999999999.99 ;
type price_type is delta 0.01 digits 6;
procedure getnum(num : out price_type) is
type ll is mod 2**64;
type ip is range 0 .. 1000000 ;
type byteind is range 0 .. 7;
bytes : array (byteind) of integer range 0 .. 255 := (0..3 => 247 , 4..7=>0);
pp : ll := 0 ;
pp1 : ip;
begin
for i in bytes'range loop
pp := pp * 256;
pp := pp + ll(bytes(i));
end loop;
Ada.Text_IO.Put_Line("pp = " & ll'image(pp));
pp1 := ip(pp); -- Should range check ??
num := price_type(fx15_2(pp1)/100);
end;
price : price_type;
begin
getnum(price);
Ada.Text_IO.Put_Line("price = " & price_type'image(price));
end tstnum;
--
Waldek Hebisch
hebisch@math.uni.wroc.pl or hebisch@hera.math.uni.wroc.pl
next reply other threads:[~2003-09-20 22:50 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-20 22:50 Waldek Hebisch [this message]
2003-09-20 23:09 ` Is this a gnat bug? Ludovic Brenta
2003-09-21 2:37 ` Waldek Hebisch
-- strict thread matches above, loose matches on Subject: below --
2002-04-26 16:36 Is this a GNAT bug??? Robert Quinn
2002-04-26 17:48 ` Mark Johnson
2002-04-26 22:20 ` Robert Dewar
2002-04-29 15:45 ` Robert Quinn
2002-04-30 2:44 ` Robert Dewar
2002-04-30 14:15 ` Larry Kilgallen
2002-04-30 16:41 ` Robert Quinn
2002-04-30 18:20 ` tmoran
2002-05-01 1:31 ` Robert Quinn
2002-05-01 17:08 ` Ted Dennison
2002-05-02 1:55 ` Larry Kilgallen
2002-05-02 14:04 ` Mark Johnson
2002-05-02 15:25 ` Larry Kilgallen
2002-04-30 21:55 ` Mark Johnson
2002-05-01 22:59 ` Nick Roberts
2002-05-02 13:56 ` Mark Johnson
2002-05-02 20:19 ` Nick Roberts
2002-05-02 21:55 ` Mark Johnson
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox