• 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: Problem with reading 4-byte floats from file on Intel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with reading 4-byte floats from file on Intel


  • Subject: Re: Problem with reading 4-byte floats from file on Intel
  • From: email@hidden
  • Date: Wed, 05 Dec 2007 08:12:35 -0500

Hi jj,

The purpose of my script was to test a binary file that contains 4-byte floats (aka "small real") in a known format to see if the file was big-endian or little-endian.

The fact that the script ran fine on your Intel Mac but not on mine tells that might be a problem with reading lots of objects from a binary file. When I reduced the number of bytes I tried to read from 512 bytes (128 floats) to (for example) 128 bytes, everything was fine even on my Intel Mac. So I could certainly read and process one float at a time, if I could figure out how to do it. In AppleScript I'm not sure how to read 4 bytes, swap them (but only on Intel Mac to simulate a little endian file read), coerce to "small real", and then test. Or maybe there's a better way.

Thanks again for all of your time,

       - Rick

On 12/5/2007 7:57 AM, jj wrote:
Well, you could swap bytes before attempting to read (if that is the real
issue)... But noone of the methods I know may be faster than your C tool...


jj

* BTW, I never read a specific binary file known to contain numbers. I used
in my test a random text file, but I guess it's the same: it will just read
double-bytes and interpret them as small reals.

Hello jj,

I was reporting my experiences with Mac OS X 10.4, not 10.5.  But it is
good to know that my future testing with 10.5 would also fail.

Having found out on a non-Apple web page that (apparently) AppleScript
is always reading binary files in big-endian mode, I have abandoned this
script.  I wrote a C command line tool in just a few minutes that did
exactly what I wanted.

Thanks for your help, everybody.  If there is more information on how to
do this in AppleScript, I am still interested!

            - Rick

On 12/4/2007 7:35 PM, jj wrote:
First, running Leopard I do reiterate I get an error.
Ooops! I didn't read before this issue was Leopard-related. I thot it was
only Intel-related.

I can only confirm that reading small reals works fine in my machine, OS X
10.4.11 ;-)


jj


_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: Problem with reading 4-byte floats from file on Intel
      • From: jj <email@hidden>
References: 
 >Re: Problem with reading 4-byte floats from file on Intel (From: jj <email@hidden>)

  • Prev by Date: Re: Problem with reading 4-byte floats from file on Intel
  • Next by Date: Re: Problem with reading 4-byte floats from file on Intel
  • Previous by thread: Re: Problem with reading 4-byte floats from file on Intel
  • Next by thread: Re: Problem with reading 4-byte floats from file on Intel
  • Index(es):
    • Date
    • Thread