In comp.lang.java.programmer message <jo1p6k$ra8$
>, Fri, 4 May 2012 23:36:52, Martin Gregorie <martin@address-in-
sig.invalid> posted:
>You may use JavaScript for financial calculations. I would not.
>Item: it is normal for currency conversions to be defined as a mandatory
>algorithm defined as a set of integer calculations by the network or
>authority who control the domain that the currency conversion is made in,
>e.g S.W.I.F.T. These do not work if floating point arithmetic is used and
>so are non-compliant.
JavaScript, using IEEE 754 Doubles, is accurate for addition,
subtraction, and multiplication of integers if the operands and results
are no greater than 2^53. Division is as accurate as possible under
those conditions; one may want to use it in conjunction with Math.round
Math.floor or Math.ceil.
Assumes not using a really early Pentium CPU.
If working in dollars, quarters are safe.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)
|