Returns -1 if input is false, or 1 if input is true.
Project description
boolean_to_signed
Returns -1 if input is false, or 1 if input is true.
Install
$ pip install boolean_to_signed
Usage
from boolean_to_signed import to_signed
print(to_signed(False)); #=> -1
print(to_signed(True)); #=> 1
# use cases
x = y = value = 0
# using naive conditional assignment
if x > 0:
y += value
else:
y -= value;
# using direct assignment
y += to_signed(x > 0) * value;
About
Author
Najim Islam
License
Copyright © 2021, Najim Islam. Released under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file boolean_to_signed-1.0.1.tar.gz.
File metadata
- Download URL: boolean_to_signed-1.0.1.tar.gz
- Upload date:
- Size: 1.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f218d22faafb5e47b10afa5ce1e2f34712d5fe336df3df9b546f354f7eeac5f
|
|
| MD5 |
12c118a1436fa6123e80119e687f7770
|
|
| BLAKE2b-256 |
6a7998d05ed8207d4e4d11cd234ebcf661aaf9ebf6b94101b5d194e8accf7015
|
File details
Details for the file boolean_to_signed-1.0.1-py3-none-any.whl.
File metadata
- Download URL: boolean_to_signed-1.0.1-py3-none-any.whl
- Upload date:
- Size: 2.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
998aa337b78b2266893f66e2e7edf89df316a1a4aecbd99907ac0312027f2480
|
|
| MD5 |
08433d362d532bb03389794d2011e072
|
|
| BLAKE2b-256 |
59937ed8cd4d480140309b147025ce725cdbfa68554c790e4d831e4c9016fa29
|