Re: Broken date math on AppleScript 2.0
Re: Broken date math on AppleScript 2.0
- Subject: Re: Broken date math on AppleScript 2.0
- From: has <email@hidden>
- Date: Mon, 18 Feb 2008 16:40:45 +0000
On 18 Feb 2008, at 16:02, Doug McNutt wrote:
The largest value that can be expressed as an integer in AppleScript
is
±536870909, which is equal to ±(2^29- 3). Larger integers (positive
or negative)
are converted to real numbers (expressed in exponential notation)
when scripts
are compiled.
Perhaps it has changed but not for this 8500 running OS 9.1. A
change like that would surely be covered in a release note or
updated version of the Language Guide. Wouldn't it?
I think a few things may have changed since OS 9.1 :), but this isn't
one of them.
I do believe the limit is in Script Editor and not in the actual
events sent to and from applications.
The limit is in AppleScript. Neither Script Editor nor Apple events
have nothing to do with it.
I remember a dialog on the list involving Chris Nebel that resulted
in a conclusion that lots of languages used the upper bits as flags.
Some do, some don't. For example, Python's int type is 32-bit, whereas
Ruby's Fixnum class is 31-bit. It's an internal implementation issue:
- Python stores all objects, including ints, as heap-allocated objects.
- Ruby stores all objects as heap-allocated objects except for
Fixnums, which it stores on the stack in place of the usual VALUE
pointer, flipping the least significant bit to indicate the difference.
The latter approach is a bit better for performance as it reduces the
amount of heap objects that are created and destroyed as a script
runs, though it's marginally more complex to implement and you do lose
one bit of resolution.
Incidentally, both languages also have arbitrary-size integer types -
long and Bignum respectively - which are always heap-allocated, so
aren't limited to 32-/31-bit integers, and can be used more or less
interchangeably with their fixed-size compatriots. That said, both
languages are slightly warty in that they don't completely hide the
difference between int/long and Fixnum/Bignum - something that you
need to watch out for when testing if a given value is an integer, e.g.:
is_integer = some_value.is_a?(Fixnum)
would give a false false if some_value is a Bignum instance. Bit
sloppy of them (this isn't C, after all), but still an improvement
over AppleScript where you can't reliably represent any integer over
10^15 (the point at which its real type starts to lose accuracy).
has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
_______________________________________________
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