• 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: BIG number as string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BIG number as string


  • Subject: Re: BIG number as string
  • From: John W Baxter <email@hidden>
  • Date: Sat, 21 Dec 2002 21:52:23 -0800

At 13:43 -0800 12/21/2002, John W Baxter wrote:
>-- Pick a path name, and get the forms we need--better duplicate prevention
>desired
>set fn to (path to temporary items folder as string) & "xxxx.py"
>set fnp to quoted form of POSIX path of fn
>
>-- Unix end of line
>set newline to ASCII character of 10
>
>-- Create a temporary file and write a Python program into it
>set f to open for access file fn with write permission
>write "print 55555 * 55555" & newline to f
>close access f
>
>-- Run the Python program and delete it
>set ans to do shell script "/usr/bin/python " & fnp
>do shell script "rm " & fnp
>
>-- -ans is a string with the answer
>ans

And...of course we're not limited to multiply. Change the write to
write "print pow(2, 120)" & newline to f
and the result is
"1329227995784915872903807060280344576"

If you start now to validate that with pencil and paper, you should get the
answer about the time you're done. ;-) (pow raises the first argument to
the power of the second)

--John
--
John Baxter email@hidden Port Ludlow, WA, USA
Drive hammered: get nailed.
_______________________________________________
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.

References: 
 >BIG number as string (From: julifos <email@hidden>)
 >Re: BIG number as string (From: John W Baxter <email@hidden>)

  • Prev by Date: Re: SE2 script snippet for Mouse Speed fails???
  • Next by Date: Re: Properties not retained
  • Previous by thread: Re: BIG number as string
  • Next by thread: Re: BIG number as string
  • Index(es):
    • Date
    • Thread