Re: Same code gives different answers in 2 different scripts
Re: Same code gives different answers in 2 different scripts
- Subject: Re: Same code gives different answers in 2 different scripts
- From: Doug McNutt <email@hidden>
- Date: Thu, 4 Jun 2009 17:31:40 -0600
At 08:51 +1000 6/5/09, Shane Stanley wrote:
>On 5/6/09 7:52 AM, "Chris Page" <email@hidden> wrote:
>> Formatting a value--numeric or otherwise--as text is a separate
>> operation from rounding, multiplication or, say, concatenation and
>> filtering.
>
>Right, but it's not like there's no precedent for mixing stuff like this. A
>good example is:
>
> 1.5 as integer
>
>This used to throw an error, because of course 1.1 can't be made into an
>integer. Someone decided this wasn't helpful, so now the coercion does a
>rounding operation and then coerces the result of that.
Like it or not the authority for this kind of thing is the spreadsheet. The way a numeric value is displayed can be quite different from the way it is stored. Date sequence numbers display a dramatic difference but:
When you ROUND( ) a numeric value you do change the value stored in memory and the rounded value will be used in a later calculation that references the cell. Rounding in the middle of a long calculation is almost always a bad idea.
When you FORMAT( ) a cell with a specified number of digits the only thing that changes is the "printed" display or perhaps the characters you would get when saving as TEXT.
But rounding still goes on, as it should, during the conversion from binary to decimal text.
And my biggest problem is Apple's "rounding as taught in school". I was never taught anything like that and I really would like to know Apple's rules for remainders that are exactly 1/2 of a digit or for negative values. (I was taught, in school, that -2^2 was a negative number but that's another question.)
For known positive numbers I prefer to add 1/2 of the last+1 digit and then truncate the decimal conversion. At least I know what I'm doing.
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".
--
Applescript syntax is like English spelling:
Roughly, though not thoroughly, thought through.
_______________________________________________
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