Even in just US Dollars, Floats are bad for money. E.g., if you get involved 
with sales tax, you're better off calculating in Pennies and sprinf'ing the $ . 
in, you don't want .0000001 issues. 

Exceptions to this rule require very careful analysis.

- Bill aka n1vux


NOT SPEAKING FOR $DAYJOB


-----Original Message-----
From: Boston-pm [mailto:boston-pm-bounces+william.ricker=fmr....@mail.pm.org] 
On Behalf Of Alex Brelsfoard
Sent: Thursday, January 10, 2013 12:32 PM
To: Shlomi Fish
Cc: L-boston-pm
Subject: Re: [Boston.pm] Template toolkit and floats

Thanks Shlomi,

My boss told me not to worry about different currencies yet.  He's pushing
to get the site up asap with the bare necessities.
I actually have some similar custom code that I'll be using later when I
get more time to implement it (not my first time dealing with international
currencies).

But thanks very much for thinking of this and providing the link. That's a
nice clean collection.

--Alex


On Thu, Jan 10, 2013 at 5:19 PM, Shlomi Fish <shlo...@shlomifish.org> wrote:

> Hi Alex,
>
> On Thu, 10 Jan 2013 16:17:06 +0000
> Alex Brelsfoard <alex.brelsfo...@gmail.com> wrote:
>
> > Nevermind... Sorry... Turned out to be a JS problem actually.... parseInt
> > vs parseFloat....
> >
> > Ugh.
> >
> >
> > On Thu, Jan 10, 2013 at 4:06 PM, Alex Brelsfoard
> > <alex.brelsfo...@gmail.com>wrote:
> >
> > > Hi All,
> > >
> > > I am working on a custom shopping basket, and using Template to
> multiple
> > > the quantity of each item by its base price, and then also summing it.
> > > But I'm losing the floating points.  It's coming out as flat INTs.
> > >
> > > Any idea of how to fix this?
> > >
> > > Thanks in advance.
> > >
> > > --Alex
> > >
> >
>
> I'm glad you got your problem sorted out, but note that you should note use
> the built-in floating-point arithmetics for currency. See:
>
> * https://metacpan.org/release/Math-Currency
>
> * http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html - "What
> Every
> Computer Scientist Should Know About Floating-Point Arithmetic".
>
> Regards,
>
>         Shlomi Fish
>
> --
> -----------------------------------------------------------------
> Shlomi Fish       http://www.shlomifish.org/
> "Humanity" - Parody of Modern Life - http://shlom.in/humanity
>
> <Botje>  Khisanth =~ s/must sleep/must give Botje all my money/ .
>     - Freenode's #perl
>
> Please reply to list if it's a mailing list post - http://shlom.in/reply .
>

_______________________________________________
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm

_______________________________________________
Boston-pm mailing list
Boston-pm@mail.pm.org
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to