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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7956d7dcc9685cb5 X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: Help ... CONSTRAINT_ERROR Date: 1999/12/02 Message-ID: #1/1 X-Deja-AN: 555875567 References: <81vfu6$sem$1@tobruk.sydney.gecm.com> Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Newsgroups: comp.lang.ada Date: 1999-12-02T00:00:00+00:00 List-Id: "jxredi" writes: > Hi, > I was wondering if you could help me out with this problem (using ADA83) : > > package R_IO is new TEXT_IO.FLOAT_IO(Float); > NUM : STRING := "hi there"; > FNUM : Float := 0.75; > R_IO.PUT(NUM,FNUM); -- this is where the problem is ... but what's wrong > ?? I cleaned this up as: with Text_IO; procedure Jxredi is package R_IO is new Text_IO.Float_IO (Float); NUM : STRING := "hi there"; FNUM : Float := 0.75; begin R_IO.Put (NUM, FNUM); end Jxredi; compiling and running with GNAT gives: ./jxredi.exe > jxredi.out raised ADA.IO_EXCEPTIONS.LAYOUT_ERROR : a-tiflau.adb:218 Since GNAT comes with source code, I looked at 'a-tiflau.adb:218' (cool!). The problem is that the string NUM is too short for the canonical representation of FNUM. Note that the call to R_IO.Put writes the image of FNUM into the string NUM; is that what you wanted it to do? If you are used to C printf, you probably wanted the following output: hello there 0.75 Here's a program that does that: with Ada.Text_IO; use Ada.Text_IO; with Ada.Float_Text_IO; use Ada.Float_Text_IO; procedure Jxredi is NUM : String := "hello there"; FNUM : Float := 0.75; begin Put (NUM); Put (FNUM, Fore => 2, Aft => 2, Exp => 0); end Jxredi; ./jxredi.exe hello there 0.75 -- Stephe