[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: float<->bytes



At  1:49 PM 11/8/93 -0400, bright@ENH.NIST.GOV wrote:
>I recall seeing something on this within the last 6 months or so, but I
>can't find it... Sorry for using bandwidth...
>I would like to store arrays with floating point numbers in a disk file. 
>In other words, are there canned functions out there that give access to
>the bytes in a floating point number so that they can be put into byte
>arrays for file i/o?

Here's a message I sent in August that should help. Note, that
since the referenced functions are defined in the foreign function
interface package, you need to (require "FF") in order to get them.

----------------------------------------------------------------------

Message-Id: <9308301745.AA24133@cambridge.apple.com>
Date: Mon, 30 Aug 1993 13:59:35 -0600
To: lam@ai-pluto.jpl.nasa.gov (Ray Lam)
From: bill@cambridge.apple.com (Bill St. Clair)
Subject: Re: Accessing C floating point data type in MCL
Cc: info-mcl

At  4:26 PM 8/26/93 -0800, Ray Lam wrote:
>Hi,
>                                I'm looking for a function simular to "%get-long" but it will work on 
>a ptr to a floating point number in C. I was looking into the
>ff-source.lisp
>file and found the function "%get-x2float". Can anyone tell me what that
>function does?

(ccl::%get-x2float ptr)
  Reads a 10-byte IEEE extended float from ptr and returns it as an
MCL 8-byte float.

(ccl::%float2x float ptr)
  Stores the 8-byte MCL float as a 10-byte IEEE extended float at ptr.

(defun %safe-get-double (ptr)
  ; Reads an 8-byte IEEE double float from ptr and returns an 8-byte MCL float
  (let ((float (ccl::%copy-float 1.0)))
    (ccl::%get-double ptr float)
    float))

(ccl::%put-double flt ptr)
  Stores the 8-byte MCL float as an 8-byte IEEE double float at ptr.