Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7567
  • Last Modified:

VBScript/ASP always round up

Hi, is there a way to make my numbers always round up, say i have 1.1, i want it to always round up to 2, anyone know of a way of doing this, as the Round() function seems to go up or down depending on the decimal.
0
LTY83
Asked:
LTY83
  • 4
1 Solution
 
fritz_the_blankCommented:
You bet:

function roundUp(numToRound)
  roundUp = Int(numToRound + .5)
end function

FtB
0
 
fritz_the_blankCommented:
Oops, that's not right. That should be:

function roundUp(numToRound)
  roundUp = Round(numToRound + .5)
end function

FtB

0
 
fritz_the_blankCommented:
The idea is that anything above .5 will round up, anything below downwards. Adding .5 to the value will always force a round up.

FtB
0
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
LTY83Author Commented:
wow, quick, easy, man why didn't i think of that, thanks again! :)
0
 
ClifCommented:
dim fNumber

fNumber = 1.1

fNewNumber = int(fNumber) + abs((fNumber - int(fNumber)) <> 0)

response.write(fNewNumber)
0
 
fritz_the_blankCommented:
Glad to have helped,

FtB
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now