As a class assignment I wouldn't expect using Val() to be acceptable.

More likely the String of decimal digits is supposed to be converted manually to a numeric type like Long before being converted back to a String of binary digits.

Anything less is just sad.