• 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: Same code gives different answers in 2 different scripts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Same code gives different answers in 2 different scripts


  • Subject: Re: Same code gives different answers in 2 different scripts
  • From: "Mark J. Reed" <email@hidden>
  • Date: Thu, 4 Jun 2009 20:22:27 -0400

On Thu, Jun 4, 2009 at 7:31 PM, Doug McNutt <email@hidden> wrote:
> If INT(1.5001) comes out as 2 in AppleScript  I would be very surprised - and disappointed. That's simply not what INT( ) does in other languages. It means "integer part of".

Well, first of all, it's not INT().  It's "as integer".  It's a
coercion, not a function, and the rules of such coercion are
essentially arbitrary.
Besides, even INT() is ambiguous.  Should INT(-1.5) return -1 or -2?

If you want the greatest integer smaller than the number, you can ask
for it explicitly:

floor 1.5001  ==> 1.0

or

(floor 1.5001) as integer ==> 1

But this I don't get:

floor(1.5001) as integer ==> 2.0

I don't know how that can parse as "floor(1.5001 as integer)" with the
parens where they are.

?!?



--
Mark J. Reed <email@hidden>
 _______________________________________________
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: Operator vs. Command precedence
      • From: Chris Page <email@hidden>
    • Re: Same code gives different answers in 2 different scripts
      • From: Stan Cleveland <email@hidden>
References: 
 >Re: Same code gives different answers in 2 different scripts (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Same code gives different answers in 2 different scripts
  • Next by Date: Re: Same code gives different answers in 2 different scripts
  • Previous by thread: Re: Same code gives different answers in 2 different scripts
  • Next by thread: Re: Same code gives different answers in 2 different scripts
  • Index(es):
    • Date
    • Thread