Skip to main content

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 None if unsupported.

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: If True, returns the minimum normalized value; if False, returns the minimum denormalized value (default is True).
  • Returns:
    • Minimum value for the floating-point number, or None if unsupported.

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


Download files

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

Source Distribution

maxbits-1.0.2.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

maxbits-1.0.2-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file maxbits-1.0.2.tar.gz.

File metadata

  • Download URL: maxbits-1.0.2.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for maxbits-1.0.2.tar.gz
Algorithm Hash digest
SHA256 7c77947efefad4c5d1864a6f25676db3051973b19ff80c6bc36ea787df94b7a7
MD5 2ade09ac9a06c391785eaf18363db49c
BLAKE2b-256 b15332bbc817f325213bd234519f71851d3a6f79d079ffd96101f1b6954cdbdb

See more details on using hashes here.

File details

Details for the file maxbits-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: maxbits-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for maxbits-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 efa000f71c77a03f092be1df7311a31e791381315e539da499cc285e17a2092f
MD5 6edd390a54b86b13c8eaa9cc931eed27
BLAKE2b-256 e380aea1fab2be96cd0a4aa61a604b62b18469f67b294804d8a78df19d7d062b

See more details on using hashes here.

Supported by

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