Rounding numbers with decimals to become whole numbers is something that you may sometimes need to do. Unfortunatly Hitop has no function to enable you to do this, but Jon Anderson has come up with a way to do it.
Assuming that the number you want rounding up is called NOTROUNDED, you can created a new variable (here called ROUNDED) using the following code:
This should all be on one line, but is shown here on multiple lines for clarity. This code will work even if you enter a whole number in.
This doesn't particularly look very nice, but it should do the job!
First thing that happens is that any numbers after the decimal point in NOTROUNDED are put into a new decimal number, which is then multipled by 2.
We then look at the first part of this number (before the decimal point). If this is greater than 1, then our number should be rounded up (ie NOTROUNDED has a decimal point of .5 or bigger). If it is 0, then the number shouldn't be rounded up.
We then add either 0 or 1 to NOTROUNDED, and discard the decimal value. And hence you have a number that is rounded up or down as appropiate.
Sites in the network