SPONSORS:






User Tag List

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)

    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)

    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)

    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)

    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
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 11:04 PM.

Copyright BetaSoft Inc.