A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: number with decimal places, decimals only needed

  1. #1
    Senior Member
    Join Date
    Nov 2001
    Posts
    137

    get the deciaml part of a number to the hundreth

    Hi if i have a number like 2.345645 and i only require .34 how would one get only the decimal to the hundreth ?

    var num = 2.345645;


    .34 or .35 if rounding applied; rounding does no affect me that much so i don't care if its applied.

    Thanks!
    Last edited by havey; 09-23-2007 at 04:15 PM.

  2. #2
    Knows where you live
    Join Date
    Oct 2004
    Posts
    944
    Multiply it by 100, Math.round and divide it by 100.
    The greatest pleasure in life is doing what people say you cannot do.
    - Walter Bagehot
    The height of cleverness is to be able to conceal it.
    - Francois de La Rochefoucauld

  3. #3
    Senior Member
    Join Date
    Nov 2001
    Posts
    137
    hi, did something different:

    math.floor(num)-num


    thanks for teaching me math.floor !

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center