• 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: get eof real?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: get eof real?


  • Subject: Re: get eof real?
  • From: Christopher Nebel <email@hidden>
  • Date: Sun, 28 Sep 2003 21:11:32 -0700

On Sep 26, 2003, at 2:58 PM, Emmanuel wrote:

At 8:44 AM -0700 26/09/03, Paul Berkowitz wrote:
'double integer' is a real. It means it's a floating point, a 'double', not a standard integer.

It's minor, but I'm afraid this statement could be a little misleading. 'double integer' is not a floating point. What may have confused you is that when AppleScript has to make a double integer into a string, instead it makes it a real first.

There are two numeric classes that I know that are coded on 4 bytes: integer and small real.
There are two numeric classes that I know that are coded on 8 bytes: double integer and real.

Still not quite right. This has to do with Apple Event transport types versus types AppleScript understands. In the Apple event, the size is a "double integer" -- that is, a 64-bit integer, as opposed to the usual 32-bit variety. As a few people have pointed out, this is because files can be larger than 4GB. When AppleScript receives this, it turns it into a "real", which is stored as an IEEE 754 double-precision floating point number, which happens to also take up 64 bits. AppleScript never stores 64-bit integers internally.

Particularly astute readers may notice a problem here: since a floating point number needs both exponent and mantissa bits, a 64-bit floating point number can't accurately store all possible 64-bit integers, because there have to be fewer than 64 mantissa bits. In this case, there are 53. Therefore, because the "get eof" result is turned into a real, it will not be precisely accurate if the file size is bigger than 53 bits, i.e. 2^53 bytes, aka 8 exabytes, aka 8192 terabytes, or about 8 million gigabytes. Since most people don't have hard drives that big, it's not a significant issue yet, but it's something to watch out for. We hope to have a fix by the time it becomes a real issue for normal users.

"small real" and "real" use the binary coding of mantissa + exponent, exactly like FORTRAN did (oops, does): you can read real numbers from FORTRAN data files with AppleScript's "read as small real" or "read as real" (depending on what was stored).

Well, assuming your FORTRAN data files use IEEE 754 floating point format. Most folks do, these days.


--Chris Nebel
AppleScript Engineering
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: get eof real?
      • From: "John W. Baxter" <email@hidden>
    • Re: get eof real?
      • From: "John W. Baxter" <email@hidden>
    • Re: get eof real?
      • From: David Crowe <email@hidden>
    • Re: get eof real?
      • From: Dave Balderstone <email@hidden>
References: 
 >Re: get eof real? (From: Paul Berkowitz <email@hidden>)
 >Re: get eof real? (From: Emmanuel <email@hidden>)

  • Prev by Date: Re: Bug in (scripting) Excel.
  • Next by Date: Re: get eof real?
  • Previous by thread: Re: get eof real?
  • Next by thread: Re: get eof real?
  • Index(es):
    • Date
    • Thread