I have created a working Getter that :
Returns the stored decimal value as an unsigned binary string bits wide
string GetUnsignedBase2(int base_10, int bits) {
string base_2;
//Find binary
int remainder = 0;
for (int i = 0; i != bits; i++) {
remainder = base_10 % 2;
base_2.insert(0, to_string(remainder));
base_10 /= 2;
}
return base_2;
But now I am trying to create a Setter for it that :
Updates the value of the stored decimal integer by interpreting the parameter base 2 as an unsigned binary integer
I am unsure how to do this, so far I have:
void BaseConverter::SetUnsignedBase2(string base_2)
{
}
Aucun commentaire:
Enregistrer un commentaire