Re: Coercing Numbers
Re: Coercing Numbers
- Subject: Re: Coercing Numbers
- From: Deivy Petrescu <email@hidden>
- Date: Fri, 26 Feb 2010 16:34:30 -0500
On 26/02/2010, at 15:54 , Stan Cleveland wrote:
> 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.
>
I personally like Shane's method because it is 100% AS.
However, since sometimes AS can be a pain....
here is a solution that works with pretty large numbers
<script>
do shell script "echo '1.2345678901234567890123456789 * 10^28 / 1'|bc"
--->"12345678901234567890123456789"
</script>
Deivy Petrescu
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