New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sanctuary-int

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sanctuary-int

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

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
increased by650%
Maintainers
1
Weekly downloads
 
Created
Source

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.

> add(1, 2)
3
sub :: Int -> Int -> Int

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

> sub(1, 2)
-1
mul :: Int -> Int -> Int

Returns the product of its two arguments.

> mul(6, 7)
42
quot :: Int -> NonZeroInt -> Int

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

Throws if the divisor is zero.

See also div.

> quot(42, 5)
8

> quot(42, -5)
-8

> quot(-42, 5)
-8

> quot(-42, -5)
8
rem :: Int -> NonZeroInt -> Int

Integer remainder, satisfying:

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

Throws if the divisor is zero.

See also mod.

> rem(42, 5)
2

> rem(42, -5)
2

> rem(-42, 5)
-2

> rem(-42, -5)
-2
div :: Int -> NonZeroInt -> Int

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

Throws if the divisor is zero.

See also quot.

> div(42, 5)
8

> div(42, -5)
-9

> div(-42, 5)
-9

> div(-42, -5)
8
mod :: Int -> NonZeroInt -> Int

Integer modulus, satisfying:

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

Throws if the divisor is zero.

See also rem.

> mod(42, 5)
2

> mod(42, -5)
-3

> mod(-42, 5)
3

> mod(-42, -5)
-2
and :: Int -> Int -> Int

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

> and(parseInt('1100', 2), parseInt('1010', 2))
8
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.

> or(parseInt('1100', 2), parseInt('1010', 2))
14
xor :: Int -> Int -> Int

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

> xor(parseInt('1100', 2), parseInt('1010', 2))
6
not :: Int -> Int

Bitwise NOT, satisfying:

not(x) === -(x + 1)
> not(42)
-43
even :: Int -> Boolean

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

> even(42)
true
odd :: Int -> Boolean

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

> odd(42)
false

FAQs

Package last updated on 01 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc