Help with conversion to Binary

For my project, I would like to be able to write a handful of variables (ranging from 35 to 99) to a standard cassette tape, and then later read those variables again.
I've had a few ideas for it, one of which was to convert the variable to an array with binary numbers, and then have the second program read data from the tape and convert them-- for example, a byte with a value of 54 sent through the method would return [0, 1, 1, 0, 1, 1, 0]. The problem with this is that no one seems to have a reasonable method of converting integers to binary! I understand how binary numbers work, but so far I've been unable to find or write code like that.
Any ideas? Thanks!

Try this. Didn't run it, but should work. This will actually print it BACKWARDS, but that's just as well if you're saving the value somewhere :slight_smile:

byte value = B10010110;
short i = 8;
while (i--)
{
  Serial.print(value&1,DEC);
  value >>= 1;
}

Aha! I think that may just work...
And it does print it backwards, but like you said, that should be fine.
Thanks!

The problem with this is that no one seems to have a reasonable method of converting integers to binary!

That is because integers are already in binary so there is little need to convert them.