What I want to do is given an argument const int &i, return the bits of the binary representation of i in the form of an array of bool (And back would also be great)… Does anyone know how?
What I want to do is given an argument const int &i , return
Share
Unless you really need it to be specifically an array of bool, I’d use an
std::bitset:You can normally treat that pretty much like an array of bool, testing, setting and flipping individual bits, etc. Of course, if you want portability to something that has a different size of int, you may want to modify it to something like: