# Rounding numbers? (Release Announcements)

Rounding numbers:

How do i get a number to be rouded up at .5 or higer and rounded down at .4 or less

I tried Ceil and Floor one rounds down absolutely and the other round up absolutely

I even tried using both calculated to a variable and the dived the two seperate results how ever this failed and still produced decimals sometimes. I am usually good at thinking outside the box, but this has me stumped. maybe it is in the manual and i missed the function?

is there a way to do it? if not my program i am making will be completely useless as it will not have correct values?

here is my program which is a calculation of miles per hour converted to meter per round(1 round = 12 seconds) its for a role playing game.

rem mph to combat round move meters. not correct redo
print " miles per hour "
input mph

mpr = mph * 5.36

mps = mpr
mpm = mps * 2
mpf = mpm * 2
mpvf = mpf * 2
print " Meters Per Round(Slow) " + mps
print " Meters Per Round(medium) " + mpm
print " Meters Per Round(fast) " + mpf
print " Meters Per Round(very fast) " + mpvf

maybe someone can help

## Rounding numbers?

sorry here is the corrected program

rem mph to combat round move meters. not correct redo
print " miles per hour "
input mph

mpr = mph * 5.36

mps = mpr /8

mpm = mps * 2
mpf = mpm * 2
mpvf = mpf * 2
print " Meters Per Round(Slow) " + mps
print " Meters Per Round(medium) " + mpm
print " Meters Per Round(fast) " + mpf
print " Meters Per Round(very fast) " + mpvf
print "mpfl" + mpfl
print "mpc" + mpc

i need mps to be rounded down at .4 or less and rounded up at .5 or higher

## Rounding numbers?

Sorry i apologize i just realized i posted this in the wrong category!

## Rounding numbers?

No problem - just be more careful next time.

I would create a round function and use it like this:

input "enter a number> ", i
print i + " rounded is " + round(i)

function round(n)
# round a number n
if n > 0 then
n = n + .5
return floor(n)
else
n = n - .5
return ceil(n)
end if
end function

## Rounding numbers?

Thanks Jim i appreciate the help. :)

## Rounding numbers?

if you know you will always be dealing with a positive number the easiest and fastest way is this:

int(x+.5)

example if x is 1.2 then it will return 1 BUT if x is 1.55 it will return a 2