• 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: How to convert number from exponential form?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to convert number from exponential form?


  • Subject: Re: How to convert number from exponential form?
  • From: Barry Wainwright <email@hidden>
  • Date: Mon, 12 Jan 2009 14:25:38 +0000

set theNumbers to {1.0139648E+5, 1.0139648E+7, 1.0139648E+9}
repeat with aNumber in theNumbers
	log my normalise(aNumber)
end repeat

on normalise(theNum)
try
set {oldTIDS, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {"E"}}
set {theSignificand, theExponent} to text items of (theNum as text)
set {oldTIDS, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {"."}}
set {part1, part2} to text items of theSignificand
set AppleScript's text item delimiters to oldTIDS
on error errMsg number errNum
-- no 'E' in the number!
return theNum as text
end try
set theExponent to theExponent as integer
set part2Length to count part2
if theExponent > part2Length then
set theZeros to ""
repeat (theExponent - part2Length) times
set theZeros to theZeros & "0"
end repeat
return part1 & part2 & theZeros
else if theExponent = part2Length then
return part1 & part2
else
return part1 & (text 1 thru theExponent of part2) & "." & text (theExponent + 1) thru -1 of part2
end if
end normalise


--
Barry



On 12 Jan 2009, at 13:02, Dave wrote:

Hi All,

The following snippet:

tell application "iTunes"
set myCapacity to the capacity of source 4
return myCapacity
end tell

returns 1.0139648E+9, whereas what I want is the String "1013964800". If I do:

display dialog myCapacity, the vale displayed is actually what I want, e.g. 1013964800.

How can I convert an exponential number to it's normalized decimal equivalent?

Thanks in Advance
All the Best
Dave


_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (applescript- email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: How to convert number from exponential form?
      • From: KOENIG Yvan <email@hidden>
References: 
 >How to convert number from exponential form? (From: Dave <email@hidden>)

  • Prev by Date: Re: How to convert number from exponential form?
  • Next by Date: Re: Where to log lines go
  • Previous by thread: Re: How to convert number from exponential form?
  • Next by thread: Re: How to convert number from exponential form?
  • Index(es):
    • Date
    • Thread