Re: computing 20! all the way
Re: computing 20! all the way
- Subject: Re: computing 20! all the way
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 12 Nov 2004 09:50:28 -0800
On 11/12/04 9:43 AM, "John W. Baxter" <email@hidden> wrote:
> It hasn't yet been pointed out that the correct value was computed for this
> problem by the original AppleScript script. (Assuming that the results
> presented in the thread for various alternate methods were correct.) At
> least one of us compared results. ;-)
>
> The only challenge would be to represent it as a string with the right
> number of trailing zeros. Frankly, to automate that in AppleScript is
> harder than working around the integer limitations.
>
> 20! is close to the end of the line, however...non-zero trailing digits will
> be lost "soon".
Stringify(2.43290200817664E+18)
--> "2432902008177000000"
to Stringify(x) -- for E+ numbers
set x to x as string
set {tids, AppleScript's text item delimiters} to {AppleScript's text
item delimiters, {"E+"}}
if (count (text items of x)) = 1 then
set AppleScript's text item delimiters to tids
return x
else
set {n, z} to {text item 1 of x, (text item 2 of x) as integer}
set AppleScript's text item delimiters to tids
set i to character 1 of n
set decSepChar to character 2 of n -- "." or ","
set d to text 3 thru -1 of n
set l to count d
if l > z then
return (i & (text 1 thru z of d) & decSepChar & (text (z + 1)
thru -1 of d))
else
repeat (z - l) times
set d to d & "0"
end repeat
return (i & d)
end if
end if
end Stringify
--
Paul Berkowitz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden