• 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: Mon, 23 Dec 2002 17:40:43 -0800

At 15:22 +0000 12/22/2002, has wrote:
>John W Baxter wrote:
>
>>OK, here's a simple proof-of-concept of an approach very different from
>>those proposed. Useful for Mac OS X, recent enough to have shipped with
>>Python, or with Python installed by you in command line form.
>>
>>-- Pick a path name,
>>-- Create a temporary file and write a Python program into it
>>-- Run the Python program and delete it
>
>Smart. Can be simplified:
>
> on multiply(a, b)
> do shell script "python -c 'print " & a & " * " & b & "'"
> end multiply
>
>Seems to be good on whole numbers up to 10^16, beyond which it
>resorts to Sci notation. Python & Perl have excellent libraries
>though; perhaps there's something in those for number formatting?

The string substitution in Python using the % operator implements
essentially what can be done with printf in C (but long integers are really
long).

It bothers me that you find a 10^16 (approximate) limit...are you running
an old Python as what runs when you execute the python command? If so, you
can get long integers back by sticking an L onto the ends of the integer
strings you feed in.

It doesn't behave that way here, witness my result (posted later) with

At 21:52 -0800 12/21/2002, John W Baxter wrote:
>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"

--John


--
John Baxter email@hidden Port Ludlow, WA, USA
_______________________________________________
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: 
 >Re: BIG number as string (From: has <email@hidden>)

  • Prev by Date: Re: Get disk size from choosing a folder .... OSX
  • Next by Date: simple number question
  • Previous by thread: Re: BIG number as string
  • Next by thread: scripting Dataviz Maclink - how?
  • Index(es):
    • Date
    • Thread