| 1 |
-- PR middle-end/36575 |
| 2 |
-- reporter: Laurent Guerby <[email protected]> |
| 3 |
-- { dg-do run } |
| 4 |
|
| 5 |
procedure Conv_Decimal is |
| 6 |
|
| 7 |
type Unsigned_Over_8 is mod 2**8+2; |
| 8 |
type Signed_Over_8 is range -200 .. 200; |
| 9 |
|
| 10 |
procedure Assert(Truth: Boolean) is |
| 11 |
begin |
| 12 |
if not Truth then |
| 13 |
raise Program_Error; |
| 14 |
end if; |
| 15 |
end; |
| 16 |
|
| 17 |
type Decim is delta 0.1 digits 5; |
| 18 |
|
| 19 |
Halfway : Decim := 2.5; |
| 20 |
Neg_Half : Decim := -2.5; |
| 21 |
|
| 22 |
Big : Unsigned_Over_8; |
| 23 |
Also_Big : Signed_Over_8; |
| 24 |
|
| 25 |
begin |
| 26 |
Big := Unsigned_Over_8 (Halfway); -- Rounds up by 4.6(33). |
| 27 |
Assert(Big = 3); |
| 28 |
|
| 29 |
Also_Big := Signed_Over_8 (Halfway); -- Rounds up by 4.6(33). |
| 30 |
Assert(Also_Big = 3); |
| 31 |
|
| 32 |
Also_Big := Signed_Over_8 (Neg_Half); -- Rounds down by 4.6(33). |
| 33 |
Assert(Also_Big = -3); |
| 34 |
end; |