A Python module that provides functions to calculate the maximum and minimum values for signed and unsigned integers, as well as floating-point numbers of specified bit widths.
Project description
maxbits
maxbits is a Python module that provides functions to calculate the maximum and minimum values for signed and unsigned integers, as well as floating-point numbers of specified bit widths. This module helps in understanding the range of values that can be represented with different bit sizes.
Installation
To use the maxbits module, simply download the module using pip and import it into your Python script. No additional dependencies are required.
Functions
signed_max(x: int) -> int
Calculates the maximum value for a signed integer of the given bit width.
- Args:
x: Bit width of the signed integer.
- Returns:
- Maximum value for the signed integer.
signed_min(x: int) -> int
Calculates the minimum value for a signed integer of the given bit width.
- Args:
x: Bit width of the signed integer.
- Returns:
- Minimum value for the signed integer.
unsigned_max(x: int) -> int
Calculates the maximum value for an unsigned integer of the given bit width.
- Args:
x: Bit width of the unsigned integer.
- Returns:
- Maximum value for the unsigned integer.
unsigned_min(x: int = 0) -> int
Calculates the minimum value for an unsigned integer.
- Args:
x: Bit width of the unsigned integer (default is 0).
- Returns:
- Minimum value for the unsigned integer (always 0).
float_max(x: int) -> float
Calculates the maximum value for a floating-point number of the specified bit width (32 or 64).
- Args:
x: Bit width of the floating-point number.
- Returns:
- Maximum value for the floating-point number, or
Noneif unsupported.
- Maximum value for the floating-point number, or
float_min(x: int, n: bool = True) -> float
Calculates the minimum positive normalized or denormalized value for a floating-point number of the given bit width.
- Args:
x: Bit width of the floating-point number (32 or 64).n: IfTrue, returns the minimum normalized value; ifFalse, returns the minimum denormalized value (default isTrue).
- Returns:
- Minimum value for the floating-point number, or
Noneif unsupported.
- Minimum value for the floating-point number, or
Usage Example
from maxbits import signed_max, unsigned_max, float_max
print(signed_max(8)) # Output: 127
print(unsigned_max(8)) # Output: 255
print(float_max(32)) # Output: 3.4028234663852886e+38
License
This module is licensed under the Mozilla Public License 2.0. For more details, please refer to the LICENSE file.
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 maxbits-1.0.1.tar.gz.
File metadata
- Download URL: maxbits-1.0.1.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c10d26c978792d4b8c166042cad10793ffa2291a63421788d296db8ecb007dfb
|
|
| MD5 |
1903cfc7929e949e2bdc0250d073cd62
|
|
| BLAKE2b-256 |
33920fb1a7b50776fbcfeda0f7fef7c06aab55edabbac75a5fb22e5e310edadc
|
File details
Details for the file maxbits-1.0.1-py3-none-any.whl.
File metadata
- Download URL: maxbits-1.0.1-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a729f4011b1445ac6250ea13cf3fd5d4ecfb60e324550d6f887a85a942576011
|
|
| MD5 |
9b5838dafd9aa1f3e9fe9751e2f45b51
|
|
| BLAKE2b-256 |
e12af8726cf7256fb611e64869a16a48b4ca1493bed293b049f29e99001148cc
|