diff options
author | Yesudeep Mangalapilly <yesudeep@gmail.com> | 2011-08-24 16:04:32 +0530 |
---|---|---|
committer | Yesudeep Mangalapilly <yesudeep@gmail.com> | 2011-08-24 16:04:32 +0530 |
commit | aca21db98be497d68ddd29ed154425fd9b5dc74d (patch) | |
tree | 0bed19da0f4c96fd150b0626890d80c31192a997 | |
parent | 1d9ded69aff93c9b0ffbe17ef4e2eac1b90080ea (diff) | |
download | rsa-git-aca21db98be497d68ddd29ed154425fd9b5dc74d.tar.gz |
Adds the doctests for bit_size back into the function docstrings.
-rw-r--r-- | rsa/common.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/rsa/common.py b/rsa/common.py index eb95e82..8667087 100644 --- a/rsa/common.py +++ b/rsa/common.py @@ -25,6 +25,15 @@ def bit_size(num): As per definition from http://wiki.python.org/moin/BitManipulation and to match the behavior of the Python 3 API. + Usage:: + + >>> bit_size(1023) + 10 + >>> bit_size(1024) + 11 + >>> bit_size(1025) + 11 + :param num: Integer value. If num is 0, returns 0. Only the absolute value of the number is considered. Therefore, signed integers will be abs(num) @@ -74,6 +83,20 @@ def byte_size(number): Returns the number of bytes required to hold a specific long number. The number of bytes is rounded up. + + Usage:: + + >>> byte_size(1 << 1023) + 128 + >>> byte_size((1 << 1024) - 1) + 128 + >>> byte_size(1 << 1024) + 129 + + :param number: + An unsigned integer + :returns: + The number of bytes required to hold a specific long number. """ quanta, mod = divmod(bit_size(number), 8) if mod or number == 0: |