if you can assume that the character is represented by one specific bit, for example, in x86 implementations, you can simply do:
v[i] ^= !bit_generator() << SIGN_BIT_POSITION; // negate the output of // bit_generator because 0 means // negate and one means leave // unchanged.
In x86, the sign bit is MSB, so to double bit 63:
#define SIGN_BIT_POSITION 63
will do the trick.
Edit:
Based on the comments, I should add that you may need to do some extra work for this to compile, since v is a double array and bit_generator() returns an int . You can do it as follows:
union int_double { double d;
(The syntax may be slightly different for C, because you may need a typedef.)
Then define v as an int_double vector and use:
v[i].i ^= bit_generator() << SIGN_BIT_POSITION;
source share