Classic ASP - Round to 5th of a number

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sinister747
    New Member
    • Jul 2008
    • 13

    Classic ASP - Round to 5th of a number

    Hi All,

    I am trying to create a rating system for products, what i am doing is; counting all the ratings and getting the average. Then i want to round it to every 5th, so for example;

    4.3 = 4.5
    and
    4.7 = 5

    All help appreciated
  • Jerry Winston
    Recognized Expert New Member
    • Jun 2008
    • 145

    #2
    Why not limit the input?

    Code:
    ...
    <option>.5</option> 
    <option>1</option> 
    <option>1.5</option>
    <option>2</option>
    <option>2.5</option>
    ...

    anyway, here's a solution:
    Code:
    function stdRating(rating)
    
         if round(rating) < rating then 	
              rating = round(rating)+.5 
         else
              rating = round(rating)
         end if
    
         stdRating = rating
    end function

    Comment

    Working...