Ask your own question, for FREE!
Computer Science 7 Online
OpenStudy (anonymous):

why operation 257|8 returns 265? How it works

OpenStudy (anonymous):

@asnaseer @AngelWilliams16 @radar @thomaster @SolomonZelman @Shaaan14 @dan815 @ganeshie8 @hba @madrockz

ganeshie8 (ganeshie8):

is that a bitwise OR operation ?

OpenStudy (dan815):

hmm well 257+8=265

OpenStudy (anonymous):

@ganeshie8 yes

ganeshie8 (ganeshie8):

write out 257 in binary

OpenStudy (anonymous):

100000001

OpenStudy (anonymous):

@ganeshie8 I got it it works only for bits

ganeshie8 (ganeshie8):

yes :) so that took 9 digits is it ? write out 8 also in binary stuffing up 0's in the front then take OR of corresponding bits

OpenStudy (anonymous):

but my full actual question is: unsigned char x=250, z=x+7,a='8'; What is the value of the expresion: z|(a-'0')

ganeshie8 (ganeshie8):

that looks like some masking operation, let me think a bit..

ganeshie8 (ganeshie8):

first of all notice that z and x occupy 8 bits each

ganeshie8 (ganeshie8):

|dw:1406901689637:dw|

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!