From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,442eb9212004f30 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news.glorb.com!wn11feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada From: anon@anon.org (anon) Subject: Re: Problem using Ada.Text_IO.Modular_IO Reply-To: anon@anon.org (anon) References: <4eab7055-df3d-4d56-87da-8248829da1da@26g2000hsk.googlegroups.com> X-Newsreader: IBM NewsReader/2 2.0 Message-ID: Date: Thu, 10 Jul 2008 00:48:28 GMT NNTP-Posting-Host: 12.65.138.43 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1215650908 12.65.138.43 (Thu, 10 Jul 2008 00:48:28 GMT) NNTP-Posting-Date: Thu, 10 Jul 2008 00:48:28 GMT Organization: AT&T Worldnet Xref: g2news1.google.com comp.lang.ada:1069 Date: 2008-07-10T00:48:28+00:00 List-Id: 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