Solved

VBScript/ASP always round up

Posted on 2004-09-13
6
5,618 Views
Last Modified: 2012-08-13
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
Comment
Question by:LTY83
  • 4
6 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12044924
You bet:

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

FtB
0
 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 500 total points
ID: 12044936
Oops, that's not right. That should be:

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

FtB

0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12044943
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 4

Author Comment

by:LTY83
ID: 12044951
wow, quick, easy, man why didn't i think of that, thanks again! :)
0
 
LVL 10

Expert Comment

by:Clif
ID: 12044958
dim fNumber

fNumber = 1.1

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

response.write(fNewNumber)
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12044959
Glad to have helped,

FtB
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question