Re: (was Int Function) mod bug
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.