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

[MacPerl] Getting floating point numbers from binary files



-----BEGIN PGP SIGNED MESSAGE-----

Hello all -

I'm trying to convert binary files from a pre-MS-DOS computer (it even has
8 inch floppies) into comma-separated ASCII values. In these files are
32-bit real numbers (in IEEE format, i.e., 1 bit sign, 8 bit exponent, 23
bit remainder) as well as ASCII values and integer values. MacPerl seemed
suited for this task, but I can't figure out how to get the program to
read in the bytes as numbers:

open(FILE,$filename);
read(FILE,$byteone,1);
read(FILE,$bytetwo,1);
read(FILE,$bytethree,1);
read(FILE,$bytefour,1);
...some data manipulation ...
print $floatingpointequivalent;
close(FILE);

For example, if the byte sequence is 43 4E 56 41 it'll give me "CNVB"
rather than the numerical values. Can someone tell me how I can force it
to give me the integer values, or better yet, read in a four-byte sequence
and convert it directly into floating-point.

Thanks.

Chris

- -----------------------------------------------------
Christopher F. Blanford   V: 612/626-8036
180 Kolthoff Hall         F: 612/626-7541
207 Pleasant St SE        E: blanf001@tc.umn.edu
Minneapolis MN 55455      W: http://umn.edu/~blanf001
- -----------------------------------------------------

PGP keyID: 356CC429  http://pgp.ai.mit.edu/

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQCVAwUBNetgIHH2w2E1bMQpAQHVswP/fax4L+/JFLRWitgCeBo89WXKUMA9RQVc
qwhfIRjz8M4vSpvUyWCSrvspG60WvpOxRaId0E2qiT/3+6H48vt3Ac4HTvg50251
bwuDaI81VOvvLeQsOKL887vfeUTokEOfQPiRb9d2Cl0lKlbKzLuRAZUvZ2QQ+Ql7
Toh6+VGo8iQ=
=0r7V
-----END PGP SIGNATURE-----


***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch