I'm not sure whether you are looking to solve this problem in any way, or solve it in the particular way they suggest. If the former,
is probably the easiest way; if the latter, you can find out the value of individual bits of $value with $value & 1, $value & 2, $value & 4, $value & 8, etc., and form a string of "0"s and "1"s based on those.