Skip to main content
added 80 characters in body
Source Link
chrisl
  • 16.6k
  • 2
  • 18
  • 27

Hey I wrote this function to convert an bool array to int: (Math Lob included):

bool b_array[5];

int convertToInt(start_index,stop_index){ int run=0; int result=0; for(int id=start_index;id<=stop_index;id++){ result+=b_array[id] * pow(2.0,run); run++; } return result; }

bool b_array[5];

int convertToInt(start_index,stop_index){
    int run=0;
    int result=0;
    for(int id=start_index;id<=stop_index;id++){
        result+=b_array[id] * pow(2.0,run);
        run++;
    }
    return result;
} 

but it doesnt this work?

Thanks and kind regards Nic

Hey I wrote this function to convert an bool array to int: (Math Lob included):

bool b_array[5];

int convertToInt(start_index,stop_index){ int run=0; int result=0; for(int id=start_index;id<=stop_index;id++){ result+=b_array[id] * pow(2.0,run); run++; } return result; }

but it doesnt this work?

Thanks and kind regards Nic

Hey I wrote this function to convert an bool array to int: (Math Lob included):

bool b_array[5];

int convertToInt(start_index,stop_index){
    int run=0;
    int result=0;
    for(int id=start_index;id<=stop_index;id++){
        result+=b_array[id] * pow(2.0,run);
        run++;
    }
    return result;
} 

but it doesnt this work?

Thanks and kind regards Nic

Source Link
Nic
  • 3
  • 2

Need function to convert bool array to int- why doesnt this work?

Hey I wrote this function to convert an bool array to int: (Math Lob included):

bool b_array[5];

int convertToInt(start_index,stop_index){ int run=0; int result=0; for(int id=start_index;id<=stop_index;id++){ result+=b_array[id] * pow(2.0,run); run++; } return result; }

but it doesnt this work?

Thanks and kind regards Nic