If I have a x-bit value represented as 1s and 0s representing true and false respectively. How would I convert these to 8-bit bytes? I don’t want to know how to convert the number of bits to the number of bytes(x/8). I want to know how to convert something like this:
10000010 to a byte
or
100000101000001 to a float
The question is moot (without more information). Bits may be represented in multiple orders (endians), with the low order bit coming first or last. You need to have a defined endian order. Once you move from single bytes to words, the endian question becomes even more challenging since the order of bits may be different from the order of the bytes.
Moving from integers to floating point numbers is yet another level of complexity. Floating point numbers have different representations which are entirely different from the order of bits.
Portable code will use defined representations (network order, printf, etc) and stay far away from trying to hand-pack bits.