From: J. Meyer
Subject: reading 4-byte floating point numbers from file
Date: 
Message-ID: <Pine.A41.4.44.0202270904040.167494-100000@homer01.u.washington.edu>
Does anybody has any ideas how to import a large image file of 4-byte
floating point numbers into an array? I am running Franz Allegro Lisp.

Thanks
	Juergen

From: JP Massar
Subject: Re: reading 4-byte floating point numbers from file
Date: 
Message-ID: <3c7e7a05.355222091@netnews.attbi.com>
On Wed, 27 Feb 2002 09:09:09 -0800, "J. Meyer"
<·······@u.washington.edu> wrote:

>Does anybody has any ideas how to import a large image file of 4-byte
>floating point numbers into an array? I am running Franz Allegro Lisp.
>
>Thanks
>	Juergen
>

http://www.franz.com/support/documentation/6.1/doc/implementation.htm#fast-writing-reading-floats-2


You'd need to read your file as (unsigned-byte 16) bytes and two at a
time convert them to a float using excl:shorts-to-single-float, and
store it in a float array.
From: Duane Rettig
Subject: Re: reading 4-byte floating point numbers from file
Date: 
Message-ID: <4adtt86ya.fsf@beta.franz.com>
······@alum.mit.edu (JP Massar) writes:

> On Wed, 27 Feb 2002 09:09:09 -0800, "J. Meyer"
> <·······@u.washington.edu> wrote:
> 
> >Does anybody has any ideas how to import a large image file of 4-byte
> >floating point numbers into an array? I am running Franz Allegro Lisp.
> >
> >Thanks
> >	Juergen
> >
> 
> http://www.franz.com/support/documentation/6.1/doc/implementation.htm#fast-writing-reading-floats-2
> 
> 
> You'd need to read your file as (unsigned-byte 16) bytes and two at a
> time convert them to a float using excl:shorts-to-single-float, and
> store it in a float array.

Even slightly better than this is read-vector:

http://www.franz.com/support/documentation/6.1/doc/pages/operators/excl/read-vector.htm

Note the last bulleted list item close to the bottom of the page.
Write-vector is similar.

These two functions are part of the simple-streams implementation.
They were specified to allow the above capabilities especially
because it was always so painful to do reads and writes of float
bits using the older style above.  Using read-vector and write-vector,
no extra programming effort (knowledge of the underlying number of
bits represented) is needed to switch from single-float to
double-float and vice-versa.  Also, these two functions give you
control over endianness in a very efficient way.


-- 
Duane Rettig          Franz Inc.            http://www.franz.com/ (www)
1995 University Ave Suite 275  Berkeley, CA 94704
Phone: (510) 548-3600; FAX: (510) 548-8253   ·····@Franz.COM (internet)