17 Feb
2020
17 Feb
'20
12:54 p.m.
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