www.webdeveloper.com
Results 1 to 4 of 4

Thread: Calculating Percentages

  1. #1
    Join Date
    May 2005
    Location
    Usa
    Posts
    97

    Calculating Percentages

    Does anyone know how to calculate percentages? The client wants ther percentage to always be displayed as - for example - 0.100 instead of 0.1, 0.110 instead of 0.11, or if there's three digits, 0.111, et cetera. The value always has to have three trailing digits.

    I'm not sure to go about doing this because the value is taken from the database and it always gets rid of any trailing zeros. I also donít want to do anything that could mess up the actual value that's written to the database. I'm guessing I need to somehow format the value as it's being taken from the DB, but how?

  2. #2
    Join Date
    May 2003
    Location
    Between Baltimore and DC
    Posts
    3,579
    Do a search on google for (VB.NET/C#/J#/Your language here) pad number.

    Eric

  3. #3
    Join Date
    Feb 2005
    Location
    BC, Canada
    Posts
    1,098
    Math::Round allows rounding to a certain decimal, so you could go
    Code:
    Math::Round((value / total), 3);
    And you would get a percentage with three decimals.

  4. #4
    Join Date
    May 2005
    Location
    Usa
    Posts
    97

    Thumbs up

    Cheers, guys.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles