Logic to mirror byte value around 128

Posted by Kazar on Stack Overflow See other posts from Stack Overflow or by Kazar
Published on 2010-05-14T13:47:01Z Indexed on 2010/05/14 13:54 UTC
Read the original article Hit count: 184

Hey,

I have a need to mirror a byte's value around the centre of 128. So, example outputs of this function include:

In  0     Out  255
In  255   Out  0
In  128   Out  128
In  127   Out  1
In  30    Out  225
In  225   Out  30

I'm driving myself nuts with this, I'm sure I'll kick myself when I read the answers.

Cheers

© Stack Overflow or respective owner

Related posts about language-agnostic

Related posts about algorithm