perl / ifram / javascript question
Andrej Marjan
amarjan-e+AXbWqSrlAAvxtiuMwx3w at public.gmane.org
Fri Mar 16 22:30:27 UTC 2007
On March 14, 2007 09:49:25 am Madison Kelly wrote:
>
> In this case the problem is Javascript is not very good at rounding.
> This is more of an issue because this is a financial program and a
> rounding error could cost me money or, worse, charge a customer too much
> money. Perhaps a penny here or there, but regardless, it would make me
> look unprofessional.
>
As others have suggested, it's best to avoid floating point for finances.
There's a reason databases, Java and C# (among others) have
fixed-point, "decimal" types.
For instance, the Python tutorial has a decent description of floating point
representation problems: http://docs.python.org/tut/node16.html
Working accurately and precisely with floating point is actually quite
complex; be careful if you're not good at numerical analysis.
--
The Toronto Linux Users Group. Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists
More information about the Legacy
mailing list