Nightly Piano Man

# npm

Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

## sanctuary-int

3.0.0 • Public • Published

# sanctuary-int

A collection of functions which operate on 32-bit signed integers.

## API

#### `Int :: Type`

The Int type represents integers in the range [-2^31 .. 2^31).

#### `NonZeroInt :: Type`

The NonZeroInt type represents non-zero integers in the range [-2^31 .. 2^31).

#### `add :: Int -⁠> Int -⁠> Int`

Returns the sum of its two arguments.

#### `sub :: Int -⁠> Int -⁠> Int`

Returns the result of subtracting its first argument from its second argument.

#### `mul :: Int -⁠> Int -⁠> Int`

Returns the product of its two arguments.

#### `quot :: NonZeroInt -⁠> Int -⁠> Int`

Returns the result of dividing its second argument by its first argument, truncating towards zero.

Throws if the divisor is zero.

See also `div`.

#### `rem :: NonZeroInt -⁠> Int -⁠> Int`

Integer remainder, satisfying:

``````quot (y) (x) * y + rem (y) (x) === x
``````

Throws if the divisor is zero.

See also `mod`.

#### `div :: NonZeroInt -⁠> Int -⁠> Int`

Returns the result of dividing its second argument by its first argument, truncating towards negative infinity.

Throws if the divisor is zero.

See also `quot`.

#### `mod :: NonZeroInt -⁠> Int -⁠> Int`

Integer modulus, satisfying:

``````div (y) (x) * y + mod (y) (x) === x
``````

Throws if the divisor is zero.

See also `rem`.

#### `and :: Int -⁠> Int -⁠> Int`

Bitwise AND. Returns an Int with a one at each bit position at which both arguments have a one.

#### `or :: Int -⁠> Int -⁠> Int`

Bitwise OR. Returns an Int with a one at each bit position at which at least one argument has a one.

#### `xor :: Int -⁠> Int -⁠> Int`

Bitwise XOR. Returns an Int with a one at each bit position at which exactly one argument has a one.

#### `not :: Int -⁠> Int`

Bitwise NOT, satisfying:

``````not (x) === -(x + 1)
``````

#### `even :: Int -⁠> Boolean`

Returns `true` if its argument is even; `false` if it is odd.

#### `odd :: Int -⁠> Boolean`

Returns `true` if its argument is odd; `false` if it is even.

## Keywords

none

### Install

`npm i sanctuary-int`

35

3.0.0

MIT

13.4 kB

4