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,757e0f5f4cdec675 X-Google-Attributes: gid103376,public From: Gautier Subject: Re: IEEE float I/O in DEC Ada Date: 1999/06/02 Message-ID: <37556F34.C215608F@Maths.UniNe.CH>#1/1 X-Deja-AN: 484942672 Content-Transfer-Encoding: 7bit References: <374EB9A9.F226AEE7@Maths.UniNe.CH> Content-Type: text/plain; charset=us-ascii MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 1999-06-02T00:00:00+00:00 List-Id: Thank you all for your help! The link to file ada$predefined:system_.adc was decisive. The conversions work - I precise that the machine is an Alphaserver 8420 under OpenVMS V6.2. Testing works - apart a carriage return that DEC Ada adds after each binary record ! It seems even usual; dir /full outputs: ... Record format: Fixed length 4 byte records Record attributes: Carriage return carriage control But now the situation is under control... Thank you again! -- Gautier -------- http://members.xoom.com/gdemont/ PS: test programs. -- Test IEEE float output on AXP with DEC Ada with system; with sequential_io; with text_io; use text_io; procedure wr_ieee is subtype ieee_real is system.ieee_single_float; subtype real is long_float; package rio is new float_io(real); use rio; package irio is new float_io(ieee_real); use irio; package sio is new sequential_io(ieee_real); use sio; f: sio.file_type; d: constant array(1..6) of real:= ( 1.2345678901234567890, 1.0e40, 1.0e-39, -1.2345678901234567890, -1.0e40, -1.0e-39 ); function To_IEEE(r: real) return ieee_real is begin if r > real(ieee_real'last) then -- overflow return ieee_real'last; elsif r < real(ieee_real'first) then -- overflow return ieee_real'first; -- elsif abs(r) < real(ieee_real'small) then -- underflow (seems useless) -- return 0.0; else return ieee_real(r); end if; end To_IEEE; begin for i in d'range loop Put(" real "); Put(d(i)); Put(" ieee "); Put(to_ieee(d(i))); New_Line; end loop; Create(f, name=> "IEEE.DAT"); for i in d'range loop Write(f, to_ieee(d(i)) ); end loop; Close(f); end wr_ieee; $ ru wr_ieee real 1.23456789012346E+00 ieee 1.23457E+00 real 1.00000000000000E+40 ieee 3.40282E+38 real 1.00000000000000E-39 ieee 0.00000E+00 real -1.23456789012346E+00 ieee -1.23457E+00 real -1.00000000000000E+40 ieee -3.40282E+38 real -1.00000000000000E-39 ieee 0.00000E+00 -- Test IEEE float input on PC with GNAT with sequential_io; with text_io; use text_io; procedure rd_ieee is subtype ieee_real is float; package irio is new float_io(ieee_real); use irio; package sio is new sequential_io(ieee_real); use sio; f: sio.file_type; d: array(1..6) of ieee_real; begin Open(f, in_file, "IEEE.DAT"); for i in d'range loop Read(f,d(i)); Put(" ieee "); Put(d(i)); New_Line; end loop; Close(f); end; C:\USERS\GAUTIER\ADA\TESTS>rd_ieee.exe ieee 1.23457E+00 ieee 3.40282E+38 ieee 0.00000E+00 ieee -1.23457E+00 ieee -3.40282E+38 ieee 0.00000E+00