Menu

[r244]: / trunk / demos / Source / convert_checked.adb  Maximize  Restore  History

Download this file

34 lines (27 with data), 815 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
-- {{Ada/Sourceforge|convert_checked.adb}}
pragma License (Gpl);
pragma Ada_95;
with Ada.Text_IO;
procedure Convert_Checked is
type Short is range -128 .. +127;
type Byte is mod 256;
package T_IO renames Ada.Text_IO;
package M_IO is new Ada.Text_IO.Modular_IO (Byte);
A : constant Short := -1;
B : Byte;
begin
B := Byte (A);
T_IO.Put ("B = ");
M_IO.Put (Item => B, Width => 5, Base => 10);
end Convert_Checked;
----------------------------------------------------------------------------
-- $Author$
--
-- $Revision$
-- $Date$
--
-- $Id$
-- $HeadURL$
----------------------------------------------------------------------------
-- vim: textwidth=0 nowrap tabstop=8 shiftwidth=3 softtabstop=3 expandtab
-- vim: filetype=ada encoding=utf-8 fileformat=unix foldmethod=indent
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.