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

Re: Currency Numbers


  • Subject: Re: Currency Numbers
  • From: kai <email@hidden>
  • Date: Tue, 20 Jun 2006 21:23:41 +0100


On 20 Jun 2006, at 03:35, Nigel Garvey wrote:

OK. Bearing in mind Gary's historical treatise and kai's love of one-liners, how about this?

Wondered where you'd got to, Mr. G. ;-)

Very nicely optimised for performance, too - although, on my machine, this seems to *just* have the edge (by a mere squeak):

------------------

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


currency_format for -123.4

--> "-123,40" / "-123.40" (* depending on local currency formatting *)

------------------

(Incidentally, when the decimal part of the input number is .565, . 57, .575 or .58, I noticed a few rounding variations between the approaches.)

:-)

---
kai


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Currency Numbers
      • From: kai <email@hidden>
References: 
 >Re: Currency Numbers (From: "Nigel Garvey" <email@hidden>)

  • Prev by Date: Re: InDesign rectangle stroke won't set to 0 via AS?
  • Next by Date: Re: Currency Numbers
  • Previous by thread: Re: Currency Numbers
  • Next by thread: Re: Currency Numbers
  • Index(es):
    • Date
    • Thread