From: anon@anon.org (anon)
Subject: Re: Problem using Ada.Text_IO.Modular_IO
Date: Thu, 10 Jul 2008 00:48:28 GMT
Date: 2008-07-10T00:48:28+00:00 [thread overview]
Message-ID: <w%cdk.107943$102.92424@bgtnsc05-news.ops.worldnet.att.net> (raw)
In-Reply-To: 4eab7055-df3d-4d56-87da-8248829da1da@26g2000hsk.googlegroups.com
Your code works fine for me, but using the Interfaces package is a
more standardize: for unsigned 64-bits
--
-- test.adb
--
with ada.text_io ;
use ada.text_io ;
with Interfaces ; -- Defines Unsigned_64
use Interfaces ;
procedure test is
--
-- Interfaces define the following:
--
-- type Unsigned_64 is mod 2 ** 64;
-- for Unsigned_64'Size use 64; -- You may need to add this type
-- -- of statement to your version
--
package M_IO is new Ada.Text_IO.Modular_IO ( Unsigned_64 ) ;
c : constant Unsigned_64 := -5 ; -- Must declare type with a "constant"
-- statement
u : Unsigned_64 := -1 ;
begin
m_io.put ( Item => u, Width => 20, Base => 16 ) ;
new_line ;
--
-- using a constant
--
m_io.put ( Item => c, Width => 20, Base => 16 ) ;
new_line ;
end ;
In <4eab7055-df3d-4d56-87da-8248829da1da@26g2000hsk.googlegroups.com>, jujosei@googlemail.com writes:
>Dear All,
>
>I'm tying to print variables of a defined modular type to the standard
>io and a file.
>The type I'm working with is: type Unsigned is mod 2**64;
>
>Therefore I define a modular_io package to do this:
>package mio is new ada.text_io.modular_io(usigned);
>
>However, when compile my little test program (using gnatmake -gnato),
>the compiler tells me that a "Constraint Error" will be raised at
>runtime. So I tried it with only 63 bit (mod 2**63), which works fine
>with the GNAT 4.3.1 (20080420) on a 32bit Ubuntu-Linux machine.
>
>----------- test program -----------
>with ada.text_io; use ada.text_io;
>procedure test is
> type Unsigned is mod 2**64;
> package M_IO is new Ada.Text_IO.Modular_IO (Unsigned);
> u : Unsigned := -1;
>begin
> m_io.put(Item => u, Width => 20, Base => 16);
>end;
>-----------------------------------------
>
>I guess that this is a bug. However, what can I do instead of this, to
>get 64 bit words printed as hex, octal and binary?
>
>Thanks in advance!
>Cheers
>Julian Seifert
next prev parent reply other threads:[~2008-07-10 0:48 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-09 16:52 Problem using Ada.Text_IO.Modular_IO jujosei
2008-07-09 19:03 ` Anh Vo
2008-07-09 19:22 ` Adam Beneschan
2008-07-09 21:50 ` Adam Beneschan
2008-07-10 15:00 ` jujosei
2008-07-10 0:48 ` anon [this message]
2008-07-10 1:52 ` Adam Beneschan
2008-07-10 7:25 ` anon
2008-07-10 14:59 ` Adam Beneschan
2008-07-11 0:34 ` anon
2008-07-11 9:49 ` Georg Bauhaus
2008-07-11 10:05 ` christoph.grein
2008-07-11 13:21 ` John McCormick
2008-07-11 12:16 ` anon
2008-07-11 13:26 ` petter_fryklund
2008-07-11 21:10 ` anon
2008-07-12 10:06 ` Georg Bauhaus
2008-07-13 0:51 ` anon
2008-07-13 16:03 ` Georg Bauhaus
2008-07-14 2:03 ` anon
2008-07-14 13:12 ` Georg Bauhaus
2008-07-16 6:16 ` micronian2
2008-07-16 7:47 ` anon
2008-07-17 16:33 ` micronian2
2008-07-14 16:34 ` micronian2
2008-07-14 17:26 ` Georg Bauhaus
2008-07-16 6:28 ` micronian2
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox