Interger Division

I’m trying to divide between two integers, but a Float is returning. I just need an Int return. Any ideas? Appreciate.

1 Like

See the docstring for div. There’s a unicode infix operator for it, too, but I’m too lazy to go copy-paste it for you at the moment.

3 Likes
help?> div

  div(x, y)
  ÷(x, y)

  The quotient from Euclidean division. Computes x/y, truncated to an integer.

For example:

julia> div(10, 2)
5

julia> ÷(10, 2)
5

julia> typeof(div(10, 2))
Int64

julia> typeof(÷(10, 2))
Int64

You may also be interested in //. However, // will return a Rational, not an Integer.

julia> 10 // 2
5//1

julia> typeof(10 // 2)
Rational{Int64}
5 Likes

Thanks!