From: "Welter, Jason" To: Subject: Thanks for the post Date: Wednesday, March 29, 2000 1:13 PM Thanks for your post on how to reverse bytes for float types for the Mac. I needed to write Doubles to a binary file for the Mac and I extended your code. I just wanted to give you a copy based on your post: ************************************************ function swap16I(const a: Integer): Integer; begin result := (Integer($ff00) and (a shl 8)) or (Integer($00ff) and (a shr 8)); end; function swap32I(const a: LongInt): LongInt; begin result := (LongInt($ff000000) and (a shl 24)) or (LongInt($00ff0000) and (a shl 8)) or (LongInt($0000ff00) and (a shr 8)) or (LongInt($000000ff) and (a shr 24)); end; function swap32F(const a: Single): Single; // Got this from Earl F. Glynn type pint = ^LongInt; type psng = ^Single; var p: pointer; pig: pint; psg: psng; ig: LongInt; begin p := @a; pig := pint(p); ig := pig^; ig := swap32I(ig); p := @ig; psg := psng(p); result := psg^; end; function swap64I(const a: Int64): Int64; begin result := (Int64($ff00000000000000) and (a shl 56)) or (Int64($00ff000000000000) and (a shl 40)) or (Int64($0000ff0000000000) and (a shl 24)) or (Int64($000000ff00000000) and (a shl 8)) or (Int64($00000000ff000000) and (a shr 8)) or (Int64($0000000000ff0000) and (a shr 24)) or (Int64($000000000000ff00) and (a shr 40)) or (Int64($00000000000000ff) and (a shr 56)); end; function swap64F(const a: Double): Double; // Natural extention of swap32F type pInt64 = ^Int64; type pdbl = ^Double; var p: pointer; pig: pInt64; psg: pdbl; ig: Int64; begin p := @a; pig := pInt64(p); ig := pig^; ig := swap64I(ig); p := @ig; psg := pdbl(p); result := psg^; end; *********************************************************