![]() |
Python
1.0
|
Converting between different numerical bases. More...
Functions | |
def | Denary2Binary (num) |
Converts denary integer to a binary string. More... | |
def | Binary2Denary (bStr) |
Converts a binary string to a denary integer. More... | |
def | dec2hex (n) |
Converts a denary integer to hexadecimal. More... | |
def | hex2dec (s) |
Converts a string or number to a plain integer. More... | |
def | int2bin (n, count=24) |
Converts an integer to a binary string representation with an specified number of bits. More... | |
def | main () |
Variables | |
input = raw_input | |
Converting between different numerical bases.
In a positional number system, the value of each digit is determined by which place it appears in the full number. The lowest place value is the rightmost position, and each successive position to the left has a higher place value.
For example, the value of the binary number 10011 is determined by computing the place value of each of the digits of the number:
1 0 0 1 1 the binary number 2⁴ 2³ 2² 2¹ 2⁰ place values (1 * 2⁴) + (0 * 2³) + (0 * 2²) + (1 * 2¹) + (1 * 2⁰) = 16 + 0 + 0 + 2 + 1 = 19
def _01d_dec2bin.Binary2Denary | ( | bStr | ) |
Converts a binary string to a denary integer.
bStr | a binary string. |
Referenced by main().
def _01d_dec2bin.dec2hex | ( | n | ) |
Converts a denary integer to hexadecimal.
n | an integer. |
Referenced by main().
def _01d_dec2bin.Denary2Binary | ( | num | ) |
Converts denary integer to a binary string.
num | an integer. |
Referenced by main().
def _01d_dec2bin.hex2dec | ( | s | ) |
Converts a string or number to a plain integer.
The radix parameter gives the base for the conversion (which is 10 by default) and may be any integer in the range [2, 36], or zero. If radix is zero, the proper radix is determined based on the contents of string; the interpretation is the same as for integer literals.
s |
Referenced by main().
def _01d_dec2bin.int2bin | ( | n, | |
count = 24 |
|||
) |
Converts an integer to a binary string representation with an specified number of bits.
n | an integer. |
count | number of digits. |
Referenced by main().
def _01d_dec2bin.main | ( | ) |
References Binary2Denary(), dec2hex(), Denary2Binary(), hex2dec(), input, and int2bin().
_01d_dec2bin.input = raw_input |
Referenced by _08c_rightTriangle.getAllTriangles(), _01a_fibo.main(), _01a_fibo_list.main(), _01a_fibo_rec.main(), _01b_eqn2.main(), _01c_str2int.main(), main(), _01f_getDigit.main(), _02a_Arithmetic_Progression.main(), _02b_Geometric_Progression.main(), _02c_int2roman.main(), _02d_interest.main(), _02e_interest.main(), _03a_roman2int_dict.main(), _03b_int2roman.main(), _03b_int2roman_dict.main(), _03f_intercala.main(), _04c_perfect.main(), _05d_rsa.main(), _06a_palindroma.main(), _06b_palindromas_mutuas.main(), _06c_frase_palindroma.main(), _06d_anagrama.main(), _08b_xis.main(), _08b_xis_rec.main(), seq.main(), trigonometry.main(), _01e_multbin.main(), _03c_int2roman.main(), _03d_pascal.main(), _04a_prime.main(), _04d_sieve.main(), _05a_gcd.main(), _05b_cpf.main(), _07_alarme_windows.main(), _09_hanoi.main(), _10_factorize2.main(), _11_ncsub.main(), and _03d_pascal_rec.showpascal().