• 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: computing 20! all the way
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: computing 20! all the way
      • From: Emmanuel <email@hidden>
    • Re: computing 20! all the way
      • From: Martin Orpen <email@hidden>
References: 
 >Re: computing 20! all the way (From: "John W. Baxter" <email@hidden>)

  • Prev by Date: Re: computing 20! all the way
  • Next by Date: Re: Reading contents of a clipping file?
  • Previous by thread: Re: computing 20! all the way
  • Next by thread: Re: computing 20! all the way
  • Index(es):
    • Date
    • Thread