• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Binary floating point format
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binary floating point format


  • Subject: Re: Binary floating point format
  • From: Greg Parker <email@hidden>
  • Date: Thu, 30 Mar 2017 18:14:06 -0700

> On Mar 30, 2017, at 5:25 PM, Carl Hoefs <email@hidden> wrote:
>
> I have megabytes of raw legacy science datasets that I'm trying to read into my app and ingest into an array of doubles. The data is supposed to be organized as a stream of 8-byte doubles. I do not know how these datasets were generated, so I don't know what format (big/little endian, byte swapped, etc) they are in.
>
> If I read the data directly into double variables, they evaluate as very small (E-92, etc).
>
> I've tried all of these functions:
>
>  NSSwapDouble()
>  NSSwapBigDoubleToHost()
>  NSSwapLittleDoubleToHost()
>  NSConvertSwappedDoubleToHost()
>  CFConvertDoubleSwappedToHost()
>
> The above functions generally return invalidly large values (E+87, etc).
>
> Here is a hex dump of 4 binary doubles:
>
> 49BF7DE372533C05 A8C02FE3135B4F09 86C22FE37E630B05 27C2C4E3E258BA08
>
> It seems there's some structure to them, as the last byte is always in the range of 03 to A0, so maybe they somehow correspond to IEEE 754 double-precision binary floating point format?
>
> Is there yet another function I could use to parse this binary data?

There are lots of pre-IEEE floating-point formats. Here is a list of a few dozen of them:
Floating-Point Formats
http://www.quadibloc.com/comp/cp0201.htm <http://www.quadibloc.com/comp/cp0201.htm>

I doubt you will be able to guess your floating-point format unless you have a collection of known values in both IEEE format and your format. Many of the historical formats are similar enough that misinterpretation could give incorrect values that look reasonable by eye.


--
Greg Parker     email@hidden <mailto:email@hidden>     Runtime Wrangler


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >Binary floating point format (From: Carl Hoefs <email@hidden>)

  • Prev by Date: Binary floating point format
  • Next by Date: Re: Binary floating point format
  • Previous by thread: Binary floating point format
  • Next by thread: Re: Binary floating point format
  • Index(es):
    • Date
    • Thread