Skip to main content

JavaScript-flavored bitwise operations.

Project description

PyJsShift

JavaScript-flavored bitwise operations.

Usage

Import Module:

from pyjsbitwise import *

Cast int or float to 32-bit signed value:

i32cast(-2**31) # 2147483648
i32cast(2**53 / 3) # -1431655766

Bitwise not, and, or, xor like JavaScript's ~, &, |, ^:

bwnot(float("NaN")) # -1
bwand(2**32-1, 2**32-1) # -1
bwor(2**31, 2**53) # -2147483648
bwxor(2**31, 2**31-1) # -1

Shift left, right and unsigned right like JavaScript's <<, >>, >>>:

lshift(1, 32) # 1
rshift(-2, -31) # -1
urshift(-1, 0) # 4294967295

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyjsbitwise-1.0.2.tar.gz (14.5 kB view hashes)

Uploaded Source

Built Distribution

PyJsBitwise-1.0.2-py3-none-any.whl (14.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page