Re: Possible bug.
Re: Possible bug.
- Subject: Re: Possible bug.
- From: Deivy Petrescu <email@hidden>
- Date: Mon, 3 May 2004 10:37:06 -0400
At 10:23 PM -0700 5/2/04, Paul Berkowitz wrote:
On 5/2/04 8:43 PM, "deivy petrescu" <email@hidden> wrote:
Paul, sorry, but I have to take it back!
You are right. It is a problem with periodic fractions.
But looking at it again, it seems like bug.
And using your own words "inconsistent implicit coercion."
Inconsistent behavior is consisten with a bug!
If it handles complicated operations it should also handle divisions.
Long or short results. Or, not handle any at all.
That's not really the point. AppleScript can do the arithmetic.
' run script: Run a specified script or script file
run script script -- the script text (or an alias or file reference of
a script file) to run
it doesn't say anything about 'number' or 'real', does it? 'run script' can
run a text script or a script file. So give it text, like it's asking for.
If you give it a number, all bets are off. you can't call it a bug when it
fails to do what's undocumented in the first place. It so happens that some
silent coercion works when you give it a rational number but not an
irrational one. So what? You shouldn't be giving it a number in the first
place. It's awfully simple to make an explicit coercion 'as string' - every
time - so you never need to know that you could omit that for certain types
of numbers. Don't try. Forget about it. Just do what's documented and
there's no problem. Give 'run script' a string, like it wants, and be happy
it works - 100% - when the string is a compliable script source. There's no
bug.
--
Paul Berkowitz
Paul, I believe, Chris has settled it, but since
I learn a lot here, and I believe a lot of other
people do too, let us clarify some points.
Also, I think you post very relevant answers and,
thus you should be even more careful with them.
You said "it doesn't say anything about 'number'
or 'real', does it? ". Yes it does. You are
interpreting script text in the narrowest
possible way.
According to AS "run script: Run a specified
script or script file". Well, 2^3+1 is a script
according to my Script Editor, thus it is fair
game for run script script.
Also, I believe anything that behaves
inconsistently and can throw a scripter off is a
bug.
This particular problem gave me a big headache because of its characteristics.
If you run the original in SE with the Event log
window toggled on, then you see
"x is 0.111111111"
Then you copy and paste 0.111111... and it runs fine.
Because I was not looking at "run script', I
thought of a possible major breakdown in AS.
About 2 hours of unpleasant feeling if you will.
I do not know if the list is in favor of this or
not, but my personal opinion is anything that
behaves in an inconsistent manner should be
pointed out to the list as a bug, whether
bonified or not by the Apple and the AS team.
We can document it by ourselves.
At 6:27 AM -0600 5/3/04, Doug McNutt wrote:
At 23:43 -0400 5/2/04, deivy petrescu wrote:
You are right. It is a problem with periodic fractions.
With all the complaints I have about AppleScript
I just don't understand this thread.
1/9 = 0.11111111111. . .(10)
Just what did you expect for an answer? More
1's? A text string like "1/9"? Maple and
Mathematica can do that, but C can't and
AppleScript shouldn't be expected to.
Actually there's some luck involved in getting
0.2 for 1/5 when the floating point
representation of 2/10 is considered. It's not
exact in that intermediate format.
And there is a difference between "periodic
decimals" and "continued fractions". I'm fairly
sure you mean the former but both 1/9 and 1/5
are periodic in base 2.
set x to ((1 / ( - 2 ^ 2 + 1))) -- for phun
The problem is not computing 1/9. The problem is :
run script 1/2 -- this works
run script 1/9 -- this does not
I meant periodic. a/b is a rational number if a
and b are rational. Any rational number must be a
periodic decimal otherwise they would be
irrationals. It does not matter how long the
periods are, provided they are finite.
And Axel, this
run script ((1 / (2 ^ 3 + 1)) as string)
runs fine here. Are you still getting an error?
--
Regards
Saudagues
Deivy
http://www.dicas.com
_______________________________________________
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.