×

Discussion Board

Results 1 to 3 of 3

Thread: decimal number

  1. #1
    Regular Contributor
    Join Date
    Nov 2008
    Posts
    150

    decimal number

    hi,


    help,

    reduce to a decimal number

    example:

    61.4499166666667 -> 61.449916

  2. #2
    Super Contributor
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744

    Re: decimal number

    Quote Originally Posted by widetech1 View Post
    hi,


    help,

    reduce to a decimal number

    example:

    61.4499166666667 -> 61.449916
    Hi widetech1,

    Well, you can specify how many digits you want by doing this:

    Code:
    x = 61.4499166666667
    
    print "%.0f" % (x)  # prints 61
    
    print "%.1f" % (x)  # prints 61.4
    
    print "%.5f" % (x)  # prints 6.44991
    So, the number after the point determines how many digits you will have after the comma. The f after the number indicates it's a float number


    Hope it helps,

    Rafael.
    Last edited by Rafael T.; 2008-11-28 at 16:09.

  3. #3
    Regular Contributor
    Join Date
    Nov 2007
    Posts
    147

    Re: decimal number

    You might want to round first if rounding correctly is important to you:

    round(x,4)

Similar Threads

  1. C-code..unable to make sis
    By Symbian_Neil in forum Symbian
    Replies: 9
    Last Post: 2006-12-02, 07:55
  2. WML & WMLSCript problem ????
    By gemini_shooter in forum Browsing and Mark-ups
    Replies: 0
    Last Post: 2006-01-14, 06:02
  3. WML & WMLSCript problem ????
    By gemini_shooter in forum Browsing and Mark-ups
    Replies: 0
    Last Post: 2006-01-14, 06:01
  4. Personal
    By JSmith77 in forum PersonalJava
    Replies: 4
    Last Post: 2003-07-30, 12:52
  5. Unicode Song Title In NSM Ringtone
    By mcai7db3 in forum Smart Messaging
    Replies: 3
    Last Post: 2002-08-28, 06:58

Posting Permissions

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