> On 16 Feb 2020, at 09:38, ananthakrishnan15.2...@gmail.com wrote:
> 
> This module should contain operations that can be performed on binary numbers.
> In the below examples a and b are binary numbers.

Assuming you mean that a "binary number" is int then python
can do what you want I think.

> 
> binary.add(a,b)

        a + b

> binary.sub(a,b)

        a - b

> binary.mul(a,b)

        a * b

> binary.div(a,b)

        a // b

> binary.ones_complement(a)    //returns 1's complement of a.

        ~a

> binary.twos_complement(a)    //returns 2's complement of a.

        0 - a

> binary.dectobi(a)            //converts decimal "a" to binary of "a".

        If a is an int not sure what you expect this to do.

> binary.bcd(a)                //returns bcd of a.

        Need to know how many bits of a are to be convert then its an easy bit 
of code to write.


> binary.gray(a)               //returns grey code of a.

        I suspect this to be application specific.
        Are you thinking Digital TV encoding systems?
        Is it just a lookup table?

> binary.min()                 //minimizes.

        Need a definition of min

> binarybitodec                //converts binar "a" to decimal of "a".

        If a is an int not sure what you expect this to do.

Or are you assuming that  "binary number" is something else?
For example are your binary numbers of a specific bit width?
For example an int that only 10 bits are used?

In which case can you do the arithmetic operations as above and mask
down to the number of bits that you need?

Barry



> _______________________________________________
> Python-ideas mailing list -- python-ideas@python.org
> To unsubscribe send an email to python-ideas-le...@python.org
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at 
> https://mail.python.org/archives/list/python-ideas@python.org/message/YIAFNIOKFEBVVOSNQ75W4B5MAHRMTB6I/
> Code of Conduct: http://python.org/psf/codeofconduct/
> 
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/EQTNLUWMJYSEQLU4QK36VNQJEOQGKN4H/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to