In this case, then any # greater than 256 in your original dataset would have been converted to a # that represents only the 8 right-most bits with 8 bits of 0 padding adding on the right, and you will not be able to recover any number from your original data that was above 256 because it looks like the left-most 8 bits have been truncated during the failed data conversion to a 16 bit data type.įor example, given the # 27136 (01101010 00000000) in your current data, you cannot know if this original # was 106 (00000000 01101010) or 362 (00000001 01101010) or 874 (00000011 01101010), or any # that originally had a 1 within the position of bits 9-16.
UNSINGED INTEGER TO BINARY CONVERTER CODE
Was converted to: int16 = 27136 = 0圆A00 = 01101010 00000000 Hi Is there an easy way (or function) to convert a integer ( 1 to 128) to an 7bit Binary code array I found the following function String(myInt,BIN) which works (tried it with the Serial.println() function). Noticed the bolded items below are the same. Here are your two examples, converted to the original un-signed int (uint), and int16 values: It looks like in your examples that your bits have been shifted to the left by 8 bits. A smallint in SQL Server is stored as a signed int16, or 2 bytes, or 16 bits with the 16th bit reserved to indicate the sign (0 = positive, 1 = negative).