Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Currency Numbers



kai wrote on Thu, 22 Jun 2006 00:35:28 +0100:

>On 21 Jun 2006, at 21:01, Nigel Garvey wrote:

>> Interestingly, although multiplying an integer by itself is nearly  
>> twice
>> as fast as squaring it (!), the effect was for some reason almost  
>> exactly cancelled out by the two tells in my script.  :-\

>And with a little shuffling, we can take advantage of  
>both a multiplication and a single tell:
>
>------------------
>
>on currency_format for v
>	tell (v mod 1 as text) * 100 to (v div 1 as text) & (0.0 as text)'s  
>character 2 & ((it * it) ^ 0.5 + 0.5) div 1
>end currency_format
>
>currency_format for -321.255
>
>--> "-321,26" / "-321.26" (* depending on local currency format *)

Great! :-D  But it still doesn't seem to make any difference on my G5 and
may even be slower on my older machine. Maybe it's a surfeit of its
rather than of tells. Mind you, the tells were only there in the first
place to accommodate the it * it multiplication. They're not necessary
otherwise:

  on currency_format for v
    (v div 1 as text) & (0.0 as text)'s character 2 & ((((v mod 1 as
text) * 100) ^ 2) ^ 0.5 + 0.5) div 1
  end currency_format
  
  currency_format for -321.255

:-)

NG

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

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.