Place values in base two
Binary is a positional number system with base two. It uses the digits 0 and 1. From right to left, the positions represent 2⁰, 2¹, 2², and so on.
For example, 101010₂ equals 1×2⁵ + 1×2³ + 1×2¹, which is 42 in decimal.
Converting integers
To convert a positive decimal integer to binary by hand, repeatedly divide by two and record each remainder. Reading the remainders from last to first gives the binary representation.
To convert binary to decimal, multiply each set bit by its positional power of two and add the results. For large values, use an arbitrary-precision integer implementation so ordinary floating-point limits do not change the answer.