• 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 [NOT duplicate]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: BIG number as string [NOT duplicate]


  • Subject: Re: BIG number as string [NOT duplicate]
  • From: julifos <email@hidden>
  • Date: Wed, 18 Dec 2002 10:21:10 +0000

> on NumberToText(theNumber)
> set AppleScript's text item delimiters to ""
> set the theNumberAsText to theNumber as text
> if the theNumberAsText contains "E" then
> set AppleScript's text item delimiters to "E"
> set the theNumberAsText to every text item of theNumberAsText
> set AppleScript's text item delimiters to ""
> set theNumberString to item 1 of theNumberAsText
> set theSign to character 1 of item 2 of theNumberAsText
> set thePower to (characters 2 thru -1 of item 2 of theNumberAsText)
> as text
> set AppleScript's text item delimiters to "."
> set theValue to every text item of theNumberString
> set AppleScript's text item delimiters to ""
> set theValue to theValue as text
> if theSign is "+" then
> set zeroes to ""
> set valLength to (length of theValue) - 1
> repeat (thePower - valLength) times
> set zeroes to zeroes & "0"
> end repeat
> set theValue to theValue & zeroes
> set theConvertedNumber to (characters 1 thru (thePower + 1) of
> theValue) as text
> try
> set theConvertedNumber to theConvertedNumber & "." & (characters
> (thePower + 2) thru length of theValue) as text
> end try
> else
> set zeroes to ""
> repeat thePower - 1 times
> set zeroes to zeroes & "0"
> end repeat
> set theConvertedNumber to zeroes & theValue
> end if
> --repeat
> else
> return theNumber
> end if
> return theConvertedNumber
> end NumberToText
> --
> Paul Skinner
>
> On Tuesday, December 17, 2002, at 05:51 PM, julifos wrote:
>
>> Hi all...
>>
>> I'd like retrieve a string from a big-numbers-calculation, but I can't
>> :-(
>>
>> Eg, I'd like this:
>>
>> 55555 * 55555
>> --> 3086358025
>> --> rather than 3.086358025E+9
>>
>> (seems it works when displaying it in a dialog...)
>>
>> display dialog result
>>
>> JJ

Hi, Paul, all.
I've been testing this code and seems it doesn't work *here*, and it won't
work in any system whose decimal separator is not "."... (here it is ",")...

I've changed one line an added a little handler and now works rrrrrigth!...

set AppleScript's text item delimiters to getUserDecimalSeparator()

Instead of

set AppleScript's text item delimiters to "."


on getUserDecimalSeparator()
0.1 as string
return result's item 2
end getUserDecimalSeparator

JJ
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.

  • Follow-Ups:
    • Re: BIG number as string [NOT duplicate]
      • From: Paul Skinner <email@hidden>
  • Prev by Date: Re: scripting Dataviz Maclink - how?
  • Next by Date: Re: BIG number as string
  • Previous by thread: Re: Testing for a Modem Connection
  • Next by thread: Re: BIG number as string [NOT duplicate]
  • Index(es):
    • Date
    • Thread