• 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: Coercing Numbers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Coercing Numbers


  • Subject: Re: Coercing Numbers
  • From: Stan Cleveland <email@hidden>
  • Date: Fri, 26 Feb 2010 12:54:19 -0800
  • Thread-topic: Coercing Numbers

On 2/26/10 12:01 PM, "Oakley Masten" wrote:

> set x to 124.95 * 100
> -->   x = 1.2495E+4
>
> How do I get this to show up as  12495 ?

If you can live without a numeric result, there's this odd trick (discovered
by Shane Stanley, I believe) that will return larger numbers as strings:

    set x to 124.95 * 100 as meters as text
    -->   x = "12495"

    set x to 1.23456789123E+10 as meters as text
    -->   x = "12345678912.3"

    set x to 1.23456789012345E+12 as meters as text
    -->   x = "1234567890123.45"

    set x to 1.23456789012345E+15 as meters as text
    -->   x = "1234567890123450"

This method seems to top out around 15 or 16 digits before reverting back to
scientific notation, but that's based on just my casual observation.
Apparently, most any unit (gallons, miles, etc.) will work, not just meters.

HTH,
Stan C.


 _______________________________________________
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: Coercing Numbers
      • From: Shane Stanley <email@hidden>
    • Re: Coercing Numbers
      • From: Deivy Petrescu <email@hidden>
References: 
 >Coercing Numbers (From: Oakley Masten <email@hidden>)

  • Prev by Date: Re: [ANN] AppleScript Pro Sessions Florida
  • Next by Date: Re: Coercing Numbers
  • Previous by thread: Re: Coercing Numbers
  • Next by thread: Re: Coercing Numbers
  • Index(es):
    • Date
    • Thread