Re: round

new topic     » goto parent     » topic index » view thread      » older message » newer message

©koda wrote:
>
>    Part 1.1    Type: Plain Text (text/plain)
>            Encoding: quoted-printable

How about:
--------------------------------
function round(atom a)
    if a < 0 then
        return floor(a - 0.5)
    else
        return floor(a + 0.5)
end function
--------------------------------

 a =  1.3 --> round(a) :  1
 a =  1.5 --> riund(a) :  2
 a =  1.7 --> round(a) :  2
 a = -0.3 --> round(a) :  0
 a = -0.5 --> round(a) : -1
 a = -0.7 --> round(a) : -1

Have a nice day, Rolf

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu