• 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: (was Int Function) mod bug
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (was Int Function) mod bug


  • Subject: Re: (was Int Function) mod bug
  • From: "Dennis W. Manasco" <email@hidden>
  • Date: Mon, 19 Aug 2002 03:35:14 -0500

At 9:04 pm -0700 8/18/02, Christopher Nebel wrote:

AppleScript actually attempts to fudge the results of div and mod a bit to produce "better" results. We've dinked with this a couple of times, which is why some versions of AppleScript have different troublesome numbers than other versions. Personally, I'm inclined to rip all of it out, because it obviously doesn't work right in all cases, I don't believe it's possible to make it work right in all cases, and we'd at least be consistent with everyone else.

Chris --

Sorry if I'm being dense, but I don't understand why

set x to 61
set b to ((x + (2.6 - (2.6 mod 1))) - x) as integer -->(error condition)

doesn't work, but

set x to 61
set b to ((x + (2.6 - (2.6 mod 1))) - x)
set b to b div 1 --> (2 with no decimal place is output)

and

set x to 61
set b to ((x + (2.6 - (2.6 mod 1))) - x)
set b to b div 1 as integer --> (2 with no decimal place is output)

do work.

I'm probably missing something fundamental, but shouldn't 'as integer' be the same as 'set variableName to variableName div 1' (at _least_ when variableName is "near" an integer)?

I realize that this is more of a conversion than a coercion, but it seems that the programmer has explicitly asked that the number be converted if necessary. Even if conversion of "reasonable" fractions is undesirable as a result of 'as integer,' shouldn't it convert reals to integers if the absolute value of (realNumber - (realNumber div 1)) is less than some arbitrarily small value (e.g. 10^ -5)?

Thanks,

-=-Dennis
_______________________________________________
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.

References: 
 >Re: (was Int Function) mod bug (From: Christopher Nebel <email@hidden>)

  • Prev by Date: Re: getting a file list in sorted order
  • Next by Date: Interesting observation in OS X scripts menu
  • Previous by thread: Re: (was Int Function) mod bug
  • Next by thread: Re: (was Int Function) mod bug
  • Index(es):
    • Date
    • Thread