SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2003
    Location
    London
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    limiting decimal places

    Hi,
    I am doing some simple calculation with some numbers obtained from some textfields.
    The values are in the form 45.00, 50.02, 100.00, ect.

    When I perform a simple multiplication I am sometimes getting far too many decimal places that I want.

    Is there a way to limit how many decimal places my answers have?
    Maybe I have to force it to be an integer, but not sure?

    thanks

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by damonps2003
    Hi,
    I am doing some simple calculation with some numbers obtained from some textfields.
    The values are in the form 45.00, 50.02, 100.00, ect.

    When I perform a simple multiplication I am sometimes getting far too many decimal places that I want.

    Is there a way to limit how many decimal places my answers have?
    Maybe I have to force it to be an integer, but not sure?

    thanks
    try Math.round(x)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •