On 2/17/20 7:08 AM, ananthan ananthan wrote:
At last found what I was trying to convey.

A new class    >>BinaryInt(n: Integer  *, bits,signed=False)

It should accept float values.(now >> "bin(5.8)".. will raise an error).

BinaryInt(-2,4)
0b1110

I would expect this to be an error, as 'unsigned' binary integers can't be negative, or perhaps accept the C-like wrapping characteristics which would get you the above value.

Int(BinaryInt(-2,4)) In this case would be 14.

BinaryInt(5,4)
0b0101
BinaryInt(-2,4,True)
-0b010
I would expect that to be 0b1110, i.e. signed BinaryInts use their MSB as the sign bit, and the others as value bits, not to have a separate sign outside the bits.

--
Richard Damon
_______________________________________________
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/ME6LFKYULGSRXWBESU6MWEK3BNGVXFKH/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to