• 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: Simple multiplication going bizarre
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple multiplication going bizarre


  • Subject: Re: Simple multiplication going bizarre
  • From: Luther Fuller <email@hidden>
  • Date: Thu, 29 Apr 2010 09:44:05 -0500

On Apr 29, 2010, at 8:58 AM, Richard Lake wrote:
4999.0*12.5 = 62487.5

But applescript returns:

6.24875E+4

?????

How do I get around this oddity?

Here's one way ...

set selfRef to (path to me)
set x to (4999.0 * 12.5)
tell application "Finder"
set comment of selfRef to x
set numText to (comment of selfRef)
end tell
log numText

But, will this work for negative exponents? I haven't tried it, but I think not.

You can use brute force with something like this ...

on nonExp(x)
set numText to (x as text)
set AppleScript's text item delimiters to {"E", "."}
if (count text items of numText) < 3 then return numText
set intText to (text item 1 of numText)
set fracText to (text item 2 of numText)
set expNr to (text item 3 of numText) as number


-- write code here using expNr to determine where to insert the decimal point 


-- return intText & space & fracText & space & expText -- for testing only
end nonExp -----------------------


 _______________________________________________
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: Simple multiplication going bizarre
      • From: David Wolfe <email@hidden>
References: 
 >Simple multiplication going bizarre (From: Richard Lake <email@hidden>)

  • Prev by Date: Re: Simple multiplication going bizarre
  • Next by Date: Re: Simple multiplication going bizarre
  • Previous by thread: Re: Simple multiplication going bizarre
  • Next by thread: Re: Simple multiplication going bizarre
  • Index(es):
    • Date
    • Thread