Log in

No account? Create an account

Tue, Dec. 18th, 2007, 02:33 pm
I done wrong and I want to suffer for my sins

It gets worse. These all work now:
    print four.pounds."\n";               # prints "4.00"
    print four.pounds.five."\n";          # prints "4.05"
    print four.pounds.fifty."\n";         # prints "4.50"
    print four.pounds.fifty.five."\n";    # prints "4.55"

    print fifty.pence."\n";               # prints "0.50"
    print fifty.five.pence."\n";          # prints "0.55"
    print four.pounds.fifty.pence."\n";   # prints "4.55"
    print four.pounds.and.fifty.p."\n";   # prints "4.50"

    print fifty.cents."\n";               # prints "0.50"
    print fifty.five.cents."\n";          # prints "0.55"
    print four.dollars.fifty.cents."\n";  # prints "4.50"

Must. Stop. Crack. Making. Me. Go. Blind.

Wed, Dec. 19th, 2007 09:44 am (UTC)

> print four.dollars.fifty.cents."\n"; # prints "4.55"

4.50 shurely? Also, should it be printing the currency symbol (ie # prints "$4.50")? Or is that asking too much?

Wed, Dec. 19th, 2007 02:41 pm (UTC)

You're right - this was a typo in the module as well. I've updated but for any future persons reading this Paul isn't made and it was originally wrong.

As for the currency thing ... I'm torn. At the moment when it sees 'dollars' it actually silently translates that to 'pounds' behind the scenes so that I don't have to rewrite my if statements so, at the moment, when it finally prints out, it doesn't know what currency it was originally in.

I could of course change that and have something that silently converts everything to 'currency_major' and 'currency_minor' but propogates the original currency down the call stack. That way I could also check for mismatched currencies like four.pounds.and.fifty.cents.

On the other hand this is a quick hack that has spiralled dangerously out of control and, to be honest, I'm a little scared of it already :)

Wed, Dec. 19th, 2007 03:34 pm (UTC)

File under "too much to ask", then. Which is fine, this is already looking slightly Cthulu-tentacle-ish.

Thu, Dec. 20th, 2007 05:42 pm (UTC)

That way I could also check for mismatched currencies like four.pounds.and.fifty.cents.

http://en.wikipedia.org/wiki/Cypriot_pound :)