On Thu, 28 Oct 2004 08:46:16 -0500, Terry
<go**************@Rem0ve.Yahoo.com> wrote:
I am new the Javascript. I was wondering if there is a pre-built or
pre-written script that can do simple number formatting.
A Google search through the archives of this group
(<URL:http://groups.google.com/groups?q=group%3Acomp.lang.javascript>)
would turn up many answers, as would looking at the FAQ
(<URL:http://jibbering.com/faq/>) and its linked resources.
When I do a calculation of 2 floating point numbers, I always end with
with [sic] xxxx.xxxxxx. I would like to keep just the first 2 digit,
xxxx.xx.
If you want to format a currency value, you can find a function at
<URL:http://www.merlyn.demon.co.uk/js-maths.htm#Money>. Note that it
expects a value in pennies (cents), as currency-related calculations
should be performed with integers, not reals, for accuracy.
Information regarding generic rounding can be found at
<URL:http://www.merlyn.demon.co.uk/js-round.htm>.
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.