From: x@x.com (Alex Grigny de Castro) Subject: Re: Mac numeric float format? Date: 25 Sep 1999 00:00:00 GMT Message-ID: <37ece1aa.619650269@news.A2000.nl> Content-Transfer-Encoding: 7bit References: <37ec26f4.571852019@news.A2000.nl> <7shlko$b7$2@bgtnsc03.worldnet.att.net> Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@a2000.nl X-Trace: weber.a2000.nl 938271717 23931 24.132.1.94 (25 Sep 1999 15:01:57 GMT) Organization: A2000 Kabeltelevisie en Telecommunicatie Mime-Version: 1.0 NNTP-Posting-Date: 25 Sep 1999 15:01:57 GMT Newsgroups: comp.lang.pascal.delphi.misc Thanks a lot, Earl, it seems to work perfectly ! The code I used was: In the stream reading proc: var sg: Single; //... // Joint.pw is a Single BytesRead := Stream1.Read(sg, SizeOf(sg)); Joint.pw := zReverse(sg); //... The zReverse overload functions: function zReverse(a: Single): Single; type pint = ^Integer; type psng = ^Single; var p: Pointer; pig: pint; psg: psng; ig : Integer; begin p := @a; pig := pint(p); ig := pig^; ig := zReverse(ig); p := @ig; psg := psng(p); Result := psg^; end; function ZReverse(a: Integer): Integer; begin Result := ($ff000000 and (a shl 24)) or ($00ff0000 and (a shl 8)) or ($0000ff00 and (a shr 8)) or ($000000ff and (a shr 24)); end; You made my day :) Alex Grigny. On Sat, 25 Sep 1999 00:20:08 -0500, "Earl F. Glynn" wrote: >Alex Grigny de Castro wrote in message >news:37ec26f4.571852019@news.A2000.nl... >> I'm trying to read binary files produces by Macintosh software, which >> contain floating point and integers in their format. I've sorted out >> the integer bit - just reverse the order of the bytes - but am >> puzzeled by the floating point. They are blocks of 16 bytes, >> presumably containing 4 numbers (quadrions for a 3d transformation). >> Does anyone know how to do this, or know the Mac specs for this? > >My guess is that Mac floats are "big endian" IEEE values. So >the values can be 4 bytes (single) or 8 bytes (double) long. >You need to reverse the floats, just like the integers, to convert from >the Mac's big endian to the PC's little endian format. Here's >some info about how to do this in Delphi: >http://www.efg2.com/Lab/OtherProjects/Endian.htm > >For more info about IEEE floating point values, see Section B of >http://www.efg2.com/Lab/Library/Delphi/MathInfo >___ >efg > >Earl F. Glynn >Overland Park, KS USA > >efg's Computer Lab: http://www.efg2.com/Lab