binary - Why does a negative SByte number have 16 bits in VB.Net? -
binary - Why does a negative SByte number have 16 bits in VB.Net? -
i asked question before comparing numbers using "and" comparing operator in if statements , have been toying around getting head wrapped around bitwise operators. have written basic code allow me see conversion of decimal number in binary format.
private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click msgbox(converttobinary(-1)) end sub public function converttobinary(byval someinteger sbyte) string dim converted string = convert.tostring(someinteger, 2) '.padleft(8, "a"c) homecoming converted end function
notice here using sbyte paramerter - should contain 8 bits right? however, message box appears has 16 bits assigned negative numbers. positive numbers have right 8.
there no convert.tostring
overload takes sbyte
, sbyte
beingness implicitly converted short
.
vb.net binary bit signed
Comments
Post a Comment