how to convert an integer to binary in Arduino?

wvmarle:
Works for any A where B = 10 (and every B where A = 10).

I could not sleep the other night and thought about this - it did not help with the sleep :slightly_frowning_face:

AB=BA it's algebra Jim, but not as we know it. The "trick" works because although the 'B' on both sides of the equation look the same they actually have different numeric values as they are in different bases.

Any base written in that base is always 10. As @wvmarle wrote the trick always works as long as at least one of the subscripts is 10. However it works whatever base the subscript is in as long as it is 10 e.g.

Binary: 1110 = 1011 = 3 decimal

Octal: 1110 = 1011 = 9 decimal

Hexadecimal: 1110 = 1011 = 17 decimal

Hexadecimal: 1F10 = 101F = 31 decimal

Curious, but I am not sure what use it has.