[fpc-pascal] Re: Turbo Pascal/legacy data file issue.

Lowell C. Savage savage at lanl.gov
Tue Sep 20 18:14:19 CEST 2005


What I would still like to see is a "Double2Real" which goes in the 
opposite direction of the "Real2Double".  That way, I can read the data 
from the existing files and then save new data back to the same files.  The 
loss of precision is not important since the numbers we are using have 
limitations on their precision that are the limiting factor (they could 
probably be "singles" without any trouble--except that then they wouldn't 
be compatible with the data files.  And performance isn't really an issue 
since I'll do any calculations as doubles (native on x86 platform).

Thanks,

Lowell

Florian Klaempfl <F.Klaempfl at gmx.de> wrote, in part:
>Lowell C. Savage wrote:
>
> > Has anyone come up with a set of routines for converting between Turbo
> > Pascal's 6-byte "real" format and FPC's real number format?
>
>http://www.freepascal.org/docs-html/rtl/system/real2double.html

Thanks.  My apologies for not finding it earlier myself.

> > Here's a simple program to demonstrate the issue.  In Turbo Pascal 5.5
> > (Downloaded from http://bdn.borland.com/article/0,1410,20803,00.html)
> > this code generates a 12-byte file.  FPC generates a 16-byte file.
> > (Actually, the preprocessor directives shown appear to have no effect on
>
>What effect should it have?

I would like it to have the same effect whether compiled under Turbo Pascal 
5.5 or under FPC.  In both cases, it should write out a 12-byte file.  I 
don't mind if I have to put in a bunch of ifdefs to define "real48" and 
dummy "Double2Real" functions for TP or some such and redo the assignments 
to call "Double2Real".  In other words, the code can change--but the data 
(and data format) is forever.  :-)

> > this code--not complaining since the docs don't make it appear that it
> > should, just pointing it out.)
>
>The 6 byte real isn't supported by fpc because it isn't handled by the
>fpu and thus deadly slow. For maybe 12 years, every new PC has an fpu.


Heavens no!  I don't want to do !!CALCULATIONS!! with the 6-byte reals.  I 
just want to be able to read and store them in the existing files.

> > Program testrec;
> > {$IFDEF FPC}
> > {$MODE TP}
> > {$PACKRECORDS 1}
> > {$ENDIF}
> > type
> >      realrec = record
> >         t1 : real;
> >         t2 : real;
> >         end;
> >
> > var
> >    realfile : file of realrec;
> >    r : realrec;
> > begin
> >    r.t1 := 1.0;
> >    r.t2 := 2.0;
> >    assign ( realfile, 'c:\r.rfl' );
> >    rewrite ( realfile );
> >    write ( realfile, r );
> >    close ( realfile );
> > end.

Lowell C. Savage
savage at lanl.gov
505-667-6964 (office/msg)
360-961-8965 (cell/msg)
505-667-4341 (shared fax) 





More information about the fpc-pascal mailing list