You shouldn't have to mask when shifting. > in c, I'd go for the following: > > up16 = (int) (longvar & 0xFFFF0000) >> 16; > low16 = (int) (longvar & 0xFFFF);