Convert to smallint (16 bit data type), in a way that truncated the 8 left-most bits.Shift the original # to the left by 8 bits (this will add 8 bits of 0 padding added on the right-hand side),.It appears your conversion process was something like:
Assume all numbers are unsigned (positive) and represented by 12 bits.a. Unfortunately, in your second scenario (the conversion from 362 that resulted in 27136), the 1 in the 9th bit position (0000000 1 01101010) has been dropped during your data conversion. Solutions for Chapter 1.4 Problem 2E: Convert the following decimal integers to binary. Original Value 2: uint = 362 = 0x016A = 00000001 01101010 When performing an integer to binary conversion (or any other such conversion) it is always best to traverse the bits once, and again to only traverse the resulting string once - preferably traverse them at the same time. Was converted to: int16 = -29440 = 0x8D00 = 10001101 00000000 C Program to Convert Decimal to Binary using Bitwise and operator crayon-61e4c26ba0e54636253120/ Output : crayon-61e4c26ba0e5e575796719/ Above program is just to know the size of integer variable in C Programming (Borland C/C++ Compiler.) Integer number can be represented by 16 bits. 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).