Float32 from a file
- To: mathgroup at smc.vnet.net
- Subject: [mg5826] Float32 from a file
- From: rudy at msunews.cl.msu.edu (Rudolf B. Blazek)
- Date: Thu, 23 Jan 1997 03:19:30 -0500
- Organization: Michigan State University
- Sender: owner-wri-mathgroup at wolfram.com
Hi Mma group. I have to read a binary file with float32 numbers in it. The file was most likely created with a C program. 1) I am about to write a Mathematica function that will read 4 bytes at a time and compute what the real number was. 2) I am also considering writing a little C program to read the dataset and return the real numbers as ASCII. Then I would call the utility from Mathematica. Could someone tell me if they've done something like that? I like the solution 1) for being written completely in Mma. But it will be slow. I like the solution 2) for being fast and using some C built in mechanism for writing/reading such files with automatic conversion of the 4 bytes into a real number. But one needs to compile the C program for each platform, put it into some reasonable place, call it from Mma... :-((( Questions: a) Would you know how the conversion of the 4 bytes into the real number should look like? I found some reference to a booklet with an ANSI standard for the float32 real numbers, but I don't have the booklet. b) If you wrote a utility similar to what I described. Would you share it? c) Could you possibly give me a short example how float32 type is read from and external file in C, C++, or Objective C ? Thank you, a nice day to all. Rudy -- Rudy Blazek Michigan State University blazek at stt.msu.edu Department of Statistics & Probability