* Re: IEEE float I/O in DEC Ada
1999-05-28 0:00 IEEE float I/O in DEC Ada Gautier
@ 1999-05-28 0:00 ` Robert Dewar
1999-05-29 0:00 ` GitaSrinivasan
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Robert Dewar @ 1999-05-28 0:00 UTC (permalink / raw)
In article <374EB9A9.F226AEE7@Maths.UniNe.CH>,
Gautier <Gautier.deMontmollin@Maths.UniNe.CH> wrote:
> Hi all.
>
> Since DEC Ada wants either
>
> pragma float_representation(vax_float);
>
> or
>
> pragma float_representation(ieee_float);
>
> for a whole "project" and a part of mine requires
> the VAX representation, so I must use it.
>
> _But_ I wish to save results in IEEE format -
> I can live with text format but the IEEE is
> a bit more compact...
>
> DEC Ada doesn't seem to have special types or
> conversions functions for both floats sorts.
>
> Anyway, are there conversion routines available ?
>
> NB: the version is :
> "DEC Ada V3.2-8 with the Professional Development Option"
>
> TIA
You can definitely handle both types within a single program
and convert between them (we know this only too well since it
was one of the relatively difficult requirements that the
GNAT implementation had to meet in copying DEC Ada 83).
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
^ permalink raw reply [flat|nested] 5+ messages in thread
* IEEE float I/O in DEC Ada
@ 1999-05-28 0:00 Gautier
1999-05-28 0:00 ` Robert Dewar
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Gautier @ 1999-05-28 0:00 UTC (permalink / raw)
Hi all.
Since DEC Ada wants either
pragma float_representation(vax_float);
or
pragma float_representation(ieee_float);
for a whole "project" and a part of mine requires
the VAX representation, so I must use it.
_But_ I wish to save results in IEEE format -
I can live with text format but the IEEE is
a bit more compact...
DEC Ada doesn't seem to have special types or
conversions functions for both floats sorts.
Anyway, are there conversion routines available ?
NB: the version is :
"DEC Ada V3.2-8 with the Professional Development Option"
TIA
--
Gautier
--------
http://members.xoom.com/gdemont/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: IEEE float I/O in DEC Ada
1999-05-28 0:00 IEEE float I/O in DEC Ada Gautier
1999-05-28 0:00 ` Robert Dewar
@ 1999-05-29 0:00 ` GitaSrinivasan
1999-05-30 0:00 ` Thierry Lelegard
1999-06-02 0:00 ` Gautier
3 siblings, 0 replies; 5+ messages in thread
From: GitaSrinivasan @ 1999-05-29 0:00 UTC (permalink / raw)
It is not clear whether you are talking about a VAX or an Alpha AXP
platform.
OpenVMS on AXP contains routines to perform such conversions -- I would look
for :
HELP RTL_Routines LIB$
In addition, if memory serves me correctly System.t_float is a valid data
type -- so simply declaring a variable of that type and assigning your
"float" variable should do the trick :
declare
myfloat : float ;
ieee_float : system.t_float ;
begin
ieee_float := system.t_float( myfloat ) ;
end ;
I would look ada ada$predefined:system_.adc
On VAX systems, we had to develop a routine to perform these conversions. I
am not sure if the recent Open VMS releases on VAX'en would have these
routines are not.
Gautier wrote in message <374EB9A9.F226AEE7@Maths.UniNe.CH>...
>Hi all.
>
>Since DEC Ada wants either
>
> pragma float_representation(vax_float);
>
>or
>
> pragma float_representation(ieee_float);
>
>for a whole "project" and a part of mine requires
>the VAX representation, so I must use it.
>
>_But_ I wish to save results in IEEE format -
>I can live with text format but the IEEE is
>a bit more compact...
>
>DEC Ada doesn't seem to have special types or
>conversions functions for both floats sorts.
>
>Anyway, are there conversion routines available ?
>
>NB: the version is :
> "DEC Ada V3.2-8 with the Professional Development Option"
>
>TIA
>
>--
>Gautier
>
>--------
>http://members.xoom.com/gdemont/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: IEEE float I/O in DEC Ada
1999-05-28 0:00 IEEE float I/O in DEC Ada Gautier
1999-05-28 0:00 ` Robert Dewar
1999-05-29 0:00 ` GitaSrinivasan
@ 1999-05-30 0:00 ` Thierry Lelegard
1999-06-02 0:00 ` Gautier
3 siblings, 0 replies; 5+ messages in thread
From: Thierry Lelegard @ 1999-05-30 0:00 UTC (permalink / raw)
The pragma float_representation(vax_float) simply specifies
the representation format for the "standard" types named
Float.
However, the package System contains explicit (and non-standard)
type definitions for all VAX and IEEE floats. If you have
specific (and explicit) requirements for float representation,
I would suggest to use the explicit and non-standard types
and _not_ use the pragma which is confusing and error-prone.
-Thierry
________________________________________________________
Thierry Lelegard, Paris, France
E-mail: lelegard@club-internet.fr
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: IEEE float I/O in DEC Ada
1999-05-28 0:00 IEEE float I/O in DEC Ada Gautier
` (2 preceding siblings ...)
1999-05-30 0:00 ` Thierry Lelegard
@ 1999-06-02 0:00 ` Gautier
3 siblings, 0 replies; 5+ messages in thread
From: Gautier @ 1999-06-02 0:00 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1999-06-02 0:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-05-28 0:00 IEEE float I/O in DEC Ada Gautier
1999-05-28 0:00 ` Robert Dewar
1999-05-29 0:00 ` GitaSrinivasan
1999-05-30 0:00 ` Thierry Lelegard
1999-06-02 0:00 ` Gautier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox