SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Apr 2000
    Location
    San Fransisco, CA
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    How to round of decimal places into 2 decimal places

    Hi ,I'm wondering if there is any function in silk to round of the decimal places to only 2 digts, or if someone can provide me the method how to do it
    e.g number GotNumber = 2.65656899
    I want to round off this number to only 2 decimal places like 2.66

  2. #2
    Senior Member
    Join Date
    Feb 2000
    Posts
    1,497
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to round of decimal places into 2 decimal places

    GotNumber += .005 ; // round off
    GotNumber *= 100 ; // move left of decimal point

    GotNumber = [int]GotNumber ; // cast to an int to strip the fraction

    GotNumber /= 100 ;
    Print(GotNumber) ;

  3. #3
    Senior Member
    Join Date
    Jul 2002
    Location
    Paris (France)
    Posts
    182
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to round of decimal places into 2 decimal places

    Another method:

    iDec = 2
    GotNumber = 2.65656899

    sNum = Str (GotNumber, NULL, iDec)

    print (sNum) // result: 2.66

    This does the rounding for you, and you can set the number of decimal places. For more information, look up "Str" in the online help.





    ------------------
    David Genrich
    Icarian
    555 North Mathilda Ave
    Sunnyvale, CA 94086
    davidg@icarian.com

  4. #4
    Junior Member
    Join Date
    Apr 2000
    Location
    San Fransisco, CA
    Posts
    7
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: How to round of decimal places into 2 decimal places

    Thanks it was of great help, it worked

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.40 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 10.71%
vBulletin Optimisation provided by vB Optimise v2.7.1 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.3.0 (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2017 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 08:33 AM.

Copyright BetaSoft Inc.