• 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 [re-round error]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BIG number as string [re-round error]


  • Subject: Re: BIG number as string [re-round error]
  • From: julifos <email@hidden>
  • Date: Sat, 21 Dec 2002 15:03:39 +0000

> on Sat, 21 Dec 2002 16:36:25 +1300 i wrote:
>
>> run script "(999308635802549 as number)"
>> --> 9.99308635802549E+14
>
> silly me, I was thinking of {record} as string which doesn't work either.
>
> to |no round big n to text|(n)
> try
> n's string
> on error m
> tid("of ")
> set nStr to (m's text item 2)'s text 1 thru -2
> tid("")
> return nStr
> end try
> end |no round big n to text|
>
> |no round big n to text|(9.99308635802549E+14)
> --> "9.99308635802549E+14"
> _____________________________ Andy

Cool trick!
But I still get round errors when doing the conversion (tens in E+15,
hundreds in E+16, thousands in E+17, ...?):

JJ

_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-- set z to pi ^ ((pi ^ pi) * 17) --> 1.45106249391477E+308
set z to "999999308635802554" as number
{z, ndigits(z)}
--> {9.99999308635802E+17, "999999308635802000"}

to ndigits(z) --> Deivy Petrescu
set myzeros to "000000000000000000000"
-- set zs to z as string
set zs to |no round big n to text|(z)
--
set k to (offset of "E" in zs) + 1
if k = 1 then return z
set sep to (0.1 as string)'s item 2
set n to (characters (k + 1) thru -1 of zs as string) as number
set zas to (character 1 of zs) & (characters 3 thru (k - 2) of zs) as
string
if character k of zs is "-" then return ("0" & sep & characters 1 thru
(n - 1) of myzeros) & zas as string
return (characters 1 thru (n + 1) of (zas & myzeros)) as string
end ndigits

to |no round big n to text|(n) --> Andy Wylie
try
n's string
on error m
tid("of ")
set nStr to (m's text item 2)'s text 1 thru -2
tid("")
return nStr
end try
end |no round big n to text|

on tid(x)
set AppleScript's text item delimiters to x
end tid
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
_______________________________________________
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.

  • Prev by Date: Re: Properties not retained
  • Next by Date: Re: Properties not retained
  • Previous by thread: Re: BIG number as string [re-round error]
  • Next by thread: Re: BIG number as string [re-round error]
  • Index(es):
    • Date
    • Thread