c - Convert 12bit to decimal -


i convert 12bit decimal number in c language.

for example if have:

a1=0x5d a2=0xa0 (lsb bits in a2 0)

so if put these have:

0x5da , equal 1498.

could please guide me how can in c ?

a1 needs shifted 4 bits left make room bits of a2, can done a1 << 4.

then a2 needs shifted 4 bits right rid of zeros in least-significant bits, can done a2>>4.

then 2 parts combined | operator:

(a1 << 4) | (a2 >> 4); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -