**Newbie Need Help** with Math.object

Discussion in 'Javascript' started by Dobie, Sep 21, 2003.

  1. Dobie

    Dobie Guest

    I need to know if there's a Math.object that will
    make a # such as 123.4567 and round it to the
    nearest 1/100. To make the # be 123.46. I have
    seen Math.floor, Math.round, Math.random and
    other objects. But none will do what I need.
    Help ???
    The only reason I need to do this is because I have
    a list of products with their prices. And when you
    enter the quantity amount, that # gets multiplied
    by the price. And on some of the prices, a long
    integer gets returned. And it would be nice to have
    a price of $123.46 instead of $123.4567.

    TIA,
    Dobie
    Dobie, Sep 21, 2003
    #1
    1. Advertising

  2. Dobie

    DU Guest

    Dobie wrote:
    > I need to know if there's a Math.object that will
    > make a # such as 123.4567 and round it to the
    > nearest 1/100. To make the # be 123.46. I have
    > seen Math.floor, Math.round, Math.random and
    > other objects. But none will do what I need.
    > Help ???
    > The only reason I need to do this is because I have
    > a list of products with their prices. And when you
    > enter the quantity amount, that # gets multiplied
    > by the price. And on some of the prices, a long
    > integer gets returned. And it would be nice to have
    > a price of $123.46 instead of $123.4567.
    >
    > TIA,
    > Dobie


    Best is to always try to find answers by yourself in documentation and
    references or in archives posts and threads of this newsgroup. Your
    question was answered before. There is a FAQENTRY on this

    http://jibbering.com/faq/#FAQ4_6

    Also:

    toPrecision([precision])

    Parameters: precision
    An integer specifying the number of digits after the decimal point.

    http://devedge.netscape.com/library/manuals/2000/javascript/1.5/reference/number.html#1201389



    toFixed
    Returns a string representing the Number object in fixed-point notation.

    Syntax
    toFixed([fractionDigits])

    Parameters
    fractionDigits

    An integer specifying the number of digits after the decimal point.
    Defaults to zero.
    http://devedge.netscape.com/library/manuals/2000/javascript/1.5/reference/number.html#1200964

    DU
    --
    Javascript and Browser bugs:
    http://www10.brinkster.com/doctorunclear/
    - Resources, help and tips for Netscape 7.x users and Composer
    - Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
    http://www10.brinkster.com/doctorunclear/Netscape7/Netscape7Section.html
    DU, Sep 21, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. chirs
    Replies:
    18
    Views:
    757
    Chris Uppal
    Mar 2, 2004
  2. AciD_X
    Replies:
    4
    Views:
    8,092
    Jonathan Turkanis
    Apr 1, 2004
  3. Mark Healey
    Replies:
    7
    Views:
    1,474
    Tim Prince
    May 22, 2006
  4. Philipp
    Replies:
    9
    Views:
    1,110
    Mark Space
    Jul 23, 2008
  5. VK
    Replies:
    15
    Views:
    1,156
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page