Topic: Standard floating-point format?


Author: davidm@rational.com (David Moore)
Date: 26 Jan 1995 02:29:24 GMT
Raw View
hugues@isoftfr.isoft.fr (Hugues Marty) writes:

Ten years ago I would have gone Aaaaaaaaargh but these days it is
even plausible as long as you don't use any really old machines
(VAX, IBM 370, Apple SANE). If you write out IEEE 64 bit format
most machines should be able to eat it. Especially if you provide
a convertor which gets called for machines that don't have it.


So, you can use a double for the value, and you can check for byte sex
and format problems by inserting a few well-chosen values and
checking the resulting bit-patterns. If they don't match, you
do the translation otherwise you just read in (and possibly
byte swap)

Note that you want to always output in a known byte sex, or else
you need a flag in the file to say which byte-sex it was written in.
>I would like to make a portable file containing double floats (it
>should be readable no most Unix worstations and PCs).  I don't want to
>use ASCII (too simple - and too slow).  In fact I'd like to use the
>internal machine format when I read/write the file on one platform
>(with some keys in the file to know which platform the file was
>written on), then be able to interpret it when the file is read on
>another platform.  Is there somewhere some code to do that?

>Thanks,
>Hugues.
>--
>--
>Hugues MARTY:  ISoft,  Chemin de Moulon,  F-91190 Gif-sur-Yvette,  France
>e-mail: hugues@isoft.fr/phone: (33 1) 69 41 27 77/fax: (33 1) 69 41 25 32




Author: az915@FreeNet.Carleton.CA (William G. Royds)
Date: Thu, 26 Jan 1995 20:36:58 GMT
Raw View
In a previous posting, Hugues Marty (hugues@isoftfr.isoft.fr) writes:
> I would like to make a portable file containing double floats (it
> should be readable no most Unix worstations and PCs).  I don't want to
> use ASCII (too simple - and too slow).  In fact I'd like to use the
> internal machine format when I read/write the file on one platform
> (with some keys in the file to know which platform the file was
> written on), then be able to interpret it when the file is read on
> another platform.  Is there somewhere some code to do that?
>
> Thanks,
> Hugues.
> --
> --
> Hugues MARTY:  ISoft,  Chemin de Moulon,  F-91190 Gif-sur-Yvette,  France
> e-mail: hugues@isoft.fr/phone: (33 1) 69 41 27 77/fax: (33 1) 69 41 25 32
  There is an article with some code to do exactly this in the January 1995
edition of the C/C++ Users Journal( Vol 13,No. 1, pg33).
The article is entitled:

" Transferring Numeric Values Between Computers", by James A. Kuzdrall.

He uses the IEEE representation with a flag indicating Big-End/Little-End etc.
--
Bill Royds           az915@freenet.carleton.ca     C.L.B.R.R. Ag Canada
Ottawa, Ontario      ROYDSW@ncccot.agr.ca          Scientific Software Support




Author: hugues@isoftfr.isoft.fr (Hugues Marty)
Date: 25 Jan 1995 12:51:29 GMT
Raw View
I would like to make a portable file containing double floats (it
should be readable no most Unix worstations and PCs).  I don't want to
use ASCII (too simple - and too slow).  In fact I'd like to use the
internal machine format when I read/write the file on one platform
(with some keys in the file to know which platform the file was
written on), then be able to interpret it when the file is read on
another platform.  Is there somewhere some code to do that?

Thanks,
Hugues.
--
--
Hugues MARTY:  ISoft,  Chemin de Moulon,  F-91190 Gif-sur-Yvette,  France
e-mail: hugues@isoft.fr/phone: (33 1) 69 41 27 77/fax: (33 1) 69 41 25 32




Author: kdq@trans.jpl.nasa.gov (Kevin D. Quitt)
Date: 25 Jan 1995 07:51:28 -0800
Raw View
Thus wrote hugues@isoftfr.isoft.fr (Hugues Marty)
>I would like to make a portable file containing double floats (it
>should be readable no most Unix worstations and PCs).  I don't want to
>use ASCII (too simple - and too slow).

By the time you record and decode the bit and byte order, and read in every
floating point value by subroutine, you're not going to be significantly
faster than plain ASCII, and you certainly won't be anywhere near as
portable.

If you want to be gross, I suppose you could write the float as 8 hex
byte (16 ASCII digits), and read them in the appropriate order.


--
#include <standard.disclaimer>
 _
Kevin D Quitt  USA 91351-4454  96.37% of all statistics are made up