My understanding is that there is no ToString overload that takes a sbyte and it is getting explicitly cast as short. But where are these leading 1’s coming from?
Console.WriteLine("{0}", Convert.ToString((sbyte)-128, 2));
>1111111110000000
Thanks,
Gybe
Your understanding is completely right.
The 1s are caused by a thing called “sign extension“. It’s a side effect of the way 2s complement binary arithmetic works.