Script to format a currency value

Sarah Reichelt sarah.reichelt at gmail.com
Tue Mar 1 05:14:55 EST 2011


On Tue, Mar 1, 2011 at 2:55 PM, Peter Haworth <pete at mollysrevenge.com> wrote:
> OK, here's an amusing exercise in scripting for you experts out there, but I'm giving away a prize!  I will give the person who provides the best solution a copy of my band's latest CD, Aged 10 years.  the definition of "best" is strictly my opinion!  If you don;t like traditional Celtic music (including bagpipes), we;ll just do the script for the fun of it and sell the CD on eBay!!!
>
> You have an integer value that needs to be formatted into a currency value.  It is stored as a positive or negative binary value no matter how many decimal places it has (eg 10000 = $100.00). You have the following formatting characters to deal with:


Sounds like a fun challenge Pete, but this bit has me confused.
You say the numbers are stored as binary, but I don't see how 10000
binary gets to $100.00
10000 binary = 16 decimal
So I am assuming that it isn't actually binary, just the currency to 2
decimal places, only without the decimal point.

Also, can you provide some test cases showing what you want to get
back for a given set of parameters?

Cheers,
Sarah




More information about the use-livecode mailing list