Number Formatting?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terry

    Number Formatting?

    Hi,

    I am new the Javascript. I was wondering if there is a pre-built or
    pre-written script that can do simple number formatting.

    When I do a calculation of 2 floating point numbers, I always end with
    with xxxx.xxxxxx. I would like to keep just the first 2 digit, xxxx.xx.

    Thanks in advance for your help!

    Terry
  • Michael Winter

    #2
    Re: Number Formatting?

    On Thu, 28 Oct 2004 08:46:16 -0500, Terry
    <gobeyondgobeyo nd@Rem0ve.Yahoo .com> wrote:
    [color=blue]
    > I am new the Javascript. I was wondering if there is a pre-built or
    > pre-written script that can do simple number formatting.[/color]

    A Google search through the archives of this group
    (<URL:http://groups.google.c om/groups?q=group% 3Acomp.lang.jav ascript>)
    would turn up many answers, as would looking at the FAQ
    (<URL:http://jibbering.com/faq/>) and its linked resources.
    [color=blue]
    > 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.[/color]

    If you want to format a currency value, you can find a function at
    <URL:http://www.merlyn.demo n.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.demo n.co.uk/js-round.htm>.

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.

    Comment

    • Grant Wagner

      #3
      Re: Number Formatting?

      Terry wrote:
      [color=blue]
      > Hi,
      >
      > I am new the Javascript. I was wondering if there is a pre-built or
      > pre-written script that can do simple number formatting.
      >
      > When I do a calculation of 2 floating point numbers, I always end with
      > with xxxx.xxxxxx. I would like to keep just the first 2 digit, xxxx.xx.
      >
      > Thanks in advance for your help!
      >
      > Terry[/color]

      <url: http://jibbering.com/faq/#FAQ4_6 />

      --
      Grant Wagner <gwagner@agrico reunited.com>
      comp.lang.javas cript FAQ - http://jibbering.com/faq

      Comment

      Working...