This module should contain operations that can be performed on binary numbers.
In the below examples a and b are binary numbers.
binary.add(a,b)
binary.sub(a,b)
binary.mul(a,b)
binary.div(a,b)
binary.ones_complement(a)//returns 1's complement of a.
binary.twos_complement(a)//returns 2's co
I'm proposing a module that has functions intended to work with existing python
types.
Digital electronics is completely based on "binary number system".As python is
used in almost all fields,by adding a seperate module for binary containing
operations like ones complement and twos complement
I'll show the example using one's and two's complement.
>>binary.ones_complement(1101100001)
0010011110
>>binary.twos_complement(1101100001)
001001
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email
we can use int(eg:110011),using base designator(eg:b,B).
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archive
I'll show the example using one's and two's complement.
>>binary.ones_complement(110011)
001100
>>binary.twos_complement(110011)
001101
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to python-ideas-l
what about
>>binary.ones_complement(0b110011)
or should we use something like "bitstring".
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lis
What would you expect ones_complement(1100) to return? (I'm guessing you'd
expect a Python int with value 11.)
What about ones_complement(1100)? (I'm guessing that you'd also expect a
Python int with value 11 here.)
What would ones_complement(ones_complement(1100)) be?
What would ones_complem
I meant we should use base designator(1b110011).
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
wea are using 0b1101100002.
hence it will give you a syntax error.
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
M
binary.twos_complement(0b0011)==1101
binary.twos_complement(0b0011)==1101
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.py
Then can we use a new Python type that represents a "binary number",which
accepts number of bits,sign of
number.
___
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.or
a and b should be integer with base designator "b" (0b110011) .OR there should
be a_new_ Python type that represents a "binary number",which accepts number of
bits,sign of number.
___
Python-ideas mailing list -- [email protected]
To unsubscribe s
12 matches
Mail list logo