[Python-ideas] Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
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

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
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

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
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

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
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

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
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

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
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

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
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

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
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

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
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

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
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

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
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

[Python-ideas] Re: Add Binary module.

2020-02-16 Thread ananthakrishnan15 . 2001
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