Rounding variables in ASP

Results 1 to 3 of 3

Thread: Rounding variables in ASP

  1. #1
    Cheyne Guest

    Default Rounding variables in ASP

    Is it possible to round the contents of a variable in ASP?<BR><BR>EX: varPERCENT contents = 66.666666666667<BR> I need the varaible contents rounded to 66.7<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Rounding variables in ASP

    contents = formatnumber (CSng (contents), 1)

  3. #3
    Join Date
    Dec 1969

    Default MATH.Round()

    Math.Round() will round to the nearest integer.<BR>So, to round to a number of decimal places, multiply by 10,100 1000 etc, then Round, and then divide by the same number that you multiplied by<BR>Like this..<BR><BR>var myNumber= "1.2345";<BR>alert (Math.round(myNumber)); ==1<BR>alert (Math.round(myNumber*10)/10); ==1.2<BR>alert (Math.round(myNumber*100)/100); ==1.23<BR>etc..<BR>

Posting Permissions

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