It works great, but here's a simpler (and more efficient) function:
function Round(n#)
n=int(n#+0.5)
endfunction n
This snippet shows that both round functions produce the same output:
Sync On
Global Up# : Global Dn#
Do
cls
print Round(4.0),"=",Round2(4.0)
print Round(5.4),"=",Round2(5.4)
print Round(5.5),"=",Round2(5.5)
print Round(6.9),"=",Round2(6.9)
Sync
Loop
function Round(Num#)
Up#=CEIL(Num#)
Dn#=FLOOR(Num#)
If Up#-Num# > .5 then RoundedNum#=Dn# ELSE RoundedNum#=Up#
endfunction RoundedNum#
function Round2(n#)
n=int(n#+0.5)
endfunction n