Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
sanctuary-int
Advanced tools
A collection of functions which operate on 32-bit signed integers.
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 first argument from its second argument.
> sub (1) (100)
99
mul :: Int -> Int -> Int
Returns the product of its two arguments.
> mul (6) (7)
42
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
.
> quot (5) (42)
8
> quot (-5) (42)
-8
> quot (5) (-42)
-8
> quot (-5) (-42)
8
rem :: NonZeroInt -> Int -> Int
Integer remainder, satisfying:
quot (y) (x) * y + rem (y) (x) === x
Throws if the divisor is zero.
See also mod
.
> rem (5) (42)
2
> rem (-5) (42)
2
> rem (5) (-42)
-2
> rem (-5) (-42)
-2
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
.
> div (5) (42)
8
> div (-5) (42)
-9
> div (5) (-42)
-9
> div (-5) (-42)
8
mod :: NonZeroInt -> Int -> Int
Integer modulus, satisfying:
div (y) (x) * y + mod (y) (x) === x
Throws if the divisor is zero.
See also rem
.
> mod (5) (42)
2
> mod (-5) (42)
-3
> mod (5) (-42)
3
> mod (-5) (-42)
-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 (0b1100) (0b1010)
0b1000
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 (0b1100) (0b1010)
0b1110
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 (0b1100) (0b1010)
0b0110
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
A collection of functions which operate on 32-bit signed integers
The npm package sanctuary-int receives a total of 0 weekly downloads. As such, sanctuary-int popularity was classified as not popular.
We found that sanctuary-int demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 12 open source maintainers collaborating on the project.
Did you know?
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.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.