Hacker News new | past | comments | ask | show | jobs | submit login

Julia goes the ADA way, supporting both. There's

    div(x,y)   # truncated division; quotient rounded towards zero
    fld(x,y)   # floored division; quotient rounded towards -Inf
and correspondingly

    rem(x,y)   # remainder; satisfies x == div(x,y)*y + rem(x,y); sign matches x
    mod(x,y)   # modulus; satisfies x == fld(x,y)*y + mod(x,y); sign matches y
and the convenience functions

    divrem(x,y) # returns (div(x,y),rem(x,y))  ## Lotus 123 convention
    fldmod(x,y)	# returns (fld(x,y),mod(x,y))  ## Excel convention
(There's also mod1 and fld1, and there's mod2pi(x) which is more precise than mod(x, 2pi).)



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: