Re: BIG number as string
Re: BIG number as string
- Subject: Re: BIG number as string
- From: Kai Edwards <email@hidden>
- Date: Thu, 19 Dec 2002 01:37:07 +0000
on Wed, 18 Dec 2002 12:20:06 -0500, Paul Skinner <email@hidden>
wrote:
>
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...
I'm on digests, so you may have already come back on this - but here's a
quick fix anyway (which may still include other warts):
===============================
on numToTxt(n)
set {t, l} to {n as string, ""}
if "E" is not in t then return t
if t starts with "-" then set {l, t} to {"-", t's text 2 thru -1}
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, p, x, y, z} to {tid, s = "-", [NO BREAK]
(1 / 1 as string)'s character 2, x as number, d's length, ""}
if m then
set {y, z} to {1, "0" & p}
else if y > x then
set d to d's text 1 thru (x - y) & p & d's text ((x - y) + 1) thru -1
end if
repeat x - y times
set z to z & "0"
end repeat
if m then return l & z & i & d
l & i & d & z
end numToTxt
===============================
Having had enough exercise, think I'll NOW check out NG's approach to find
out how to do it properly...
--
Kai
_______________________________________________
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.