PR target/84336
[official-gcc.git] / gcc / testsuite / gnat.dg / conv_decimal.adb
blobd5199c1b48b98df1beb7c3a3a60a856c95c2ee5d
1 -- PR middle-end/36575
2 -- reporter: Laurent Guerby <laurent@guerby.net>
3 -- { dg-do run }
5 procedure Conv_Decimal is
7 type Unsigned_Over_8 is mod 2**8+2;
8 type Signed_Over_8 is range -200 .. 200;
10 procedure Assert(Truth: Boolean) is
11 begin
12 if not Truth then
13 raise Program_Error;
14 end if;
15 end;
17 type Decim is delta 0.1 digits 5;
19 Halfway : Decim := 2.5;
20 Neg_Half : Decim := -2.5;
22 Big : Unsigned_Over_8;
23 Also_Big : Signed_Over_8;
25 begin
26 Big := Unsigned_Over_8 (Halfway); -- Rounds up by 4.6(33).
27 Assert(Big = 3);
29 Also_Big := Signed_Over_8 (Halfway); -- Rounds up by 4.6(33).
30 Assert(Also_Big = 3);
32 Also_Big := Signed_Over_8 (Neg_Half); -- Rounds down by 4.6(33).
33 Assert(Also_Big = -3);
34 end;