• 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: Paul Skinner <email@hidden>
  • Date: Wed, 18 Dec 2002 12:20:06 -0500

I reworked this handler last night as well (it's really old code.) And used many of the methods you use here! I'll post mine in another message in a bit. I was very put out that you had beaten me to the punch! : ) But, I think your version might need a bit of a touch up...

numToTxt(-1.0E-12)
-->00000000000-.0

...so I think have a few minutes...

On Wednesday, December 18, 2002, at 10:10 AM, Kai Edwards wrote:

That seems to do it nicely, Paul.

It occurred to me that it might be possible to abbreviate this approach a
little further - perhaps to something like this:

==============

on numToTxt(n)
set t to n as string
if "E" is not in t then return t
set {tid, text item delimiters} to {text item delimiters, "E"}
tell t's text items to set {i, d, s, x} to item 1's [NO BREAK]
{text 1 thru 1, text 3 thru -1} & item 2's {text 1 thru 1, text 2 thru -1}
set {text item delimiters, m, x, y, z} to [NO BREAK]
{tid, s = "-", x as number, d's length, ""}
if m then
set y to 1
else if y > x then
set d to d's text 1 thru x & "." & d's text (x + 1) thru -1
end if
repeat x - y times
set z to z & "0"
end repeat
if m then return z & i & d
i & d & z
end numToTxt

==============

This modification also appears to offer a speed benefit. OMM, all values are
returned in about the same time, except that the original version can take
around 15-20% longer to return some E+ real numbers - and up 100% longer for
E+ integers. (I suspect the main culprit is the try block.)

--
Kai
--
Paul Skinner
_______________________________________________
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: Kai Edwards <email@hidden>)

  • Prev by Date: wake up from sleep
  • Next by Date: Re: Reading nested key-value pairs in plist
  • Previous by thread: Re: BIG number as string
  • Next by thread: Re: BIG number as string
  • Index(es):
    • Date
    • Thread