Working with binary

Is there any "standard" way to store data as binary?
Last edited on
You need to be more precise. You can store raw data in anything that's big enough
So, I wanted to make a genetic algorithm, using binary for the genes (1 if the gene is activated, 0 if not), so I wanted to know if there's a way to store a integer as binary in a variable by using some c++ function, so I don't have to write one function to convert decimal numbers to binary numbers...
If the number of binary digit is fixed you can use std::bitset ( It has interfaces to convert is to/from strings and longs )
Or you can keep the integer as it is and use the bitwise operators to get/set values of specific bits.
Uhm, ok, I'll use bitwise operators. Thank you for helping me o_~d
Topic archived. No new replies allowed.