## 4.2 Integers

The module `Int` contains procedures operating on integers.

`IsInt`

  > `{Int.is` `+X``` `?B``}`

  tests whether `X` is an integer.

`IsNat`

  > `{Int.isNat` `+I``` `?B``}`

  tests whether `I` is a natural number, i. e., an integer greater than or equal to `0`.

`IsOdd`

  > `{Int.isOdd` `+I``` `?B``}`

  tests whether `I` is an odd integer.

`IsEven`

  > `{Int.isEven` `+I``` `?B``}`

  tests whether `I` is an even integer.

`div`

  > `{Int.'div'` `+I1``` `+I2``` `?I3``}`

  returns `I1` integer-divided by `I2`, rounding towards `0`. `Int.'div'` can be defined as follows:

  > `local
  > fun {Div I1 I2}
  > case I1 < I2 then 0 else 1 + {Div I1 - I2 I2} end
  > end
  > in
  > fun {Int.'div' I1 I2}
  > {Div {Abs I1} {Abs I2}} *
  > case I1 * I2 >= 0 then 1 else ~1 end
  > end
  > end`

`mod`

  > `{Int.'mod'` `+I1``` `+I2``` `?I3``}`

  returns `I1` modulo `I2`. `Int.'mod'` can be defined as follows:

  > `fun {Int.'mod' I1 I2}
  > I1 - I2 * (I1 div I2)
  > end`

`IntToFloat`

  > `{Int.toFloat` `+I``` `?F``}`

  returns the float closest to the integer `I`.

`IntToString`

  > `{Int.toString` `+I``` `?S``}`

  returns the string describing the integer `I` in Oz concrete syntax.