language agnostic - Join bits using bitwise operations. Is this even possible? -
what asking if possible join bits in 2 different numbers.
a pseudo-code example:
bytes=array(0x04, 0x3f); //place bitwise black magic here print 0x043f;
another example:
bytes=array(0xff, 0xffff); //place bitwise black magic here print 0xffffff;
yet example:
bytes=array(0x34f3, 0x54fd); //place bitwise black magic here print 0x34f354fd;
i want restrict only , bitwise operators (>>
, <<
, |
, ^
, ~
, &
).
this should work @ least in php , javascript.
is possible in way?
if i'm not being clear, please ask doubts in comment.
if understand question correctly,
should answer in php:
$temp = $your_first_value << strlen(dechex($the_length_of_the_second_value_in_hex)) $result = $temp | $your_second_value print dechex($result)
update: instead of + use | operator
Comments
Post a Comment