How to convert numbers from Binary to Decimal? Please Coment!:D

Hi folks I'm looking if there is a function tha let me convertes variables from binary to decimal values... for example:

byte booleanArray[8] = {0,0,0,0,0,0,0,0}
int decimalValue = 0;

booleanArray = {1,0,1,0,1,0,1,0}; We know that "10101010" en Binary System is "170" in Decimal System...
So I want to know how I can do this converstion!:D...

Thankyou!:smiley:

Do the math:

decimal = (bA[7] * 128) + (bA[6] * 64) + (bA[5] * 32) + (bA[4] * 16) +(bA[3] * 8)+ (bA[2]*4) +(bA[1]*2)+ bA[0];

Where are these binary arrays coming from? This isn't a natural way to represent a number, and perhaps it would be possible to get your data into a format that avoids the need for this explicit conversion.

This should also work:

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);

  byte booleanArray[8] = {1, 0, 1, 0, 1, 0, 1, 0};
  byte decimalValue = 0;
  int j, temp;

  for (int i = sizeof(booleanArray) / sizeof(booleanArray[0]) - 1, j = 0; i > -1; i--) {
    decimalValue += booleanArray[j++] << i;
  }
  Serial.print(decimalValue);
}

void loop() {
  // put your main code here, to run repeatedly:

However, I agree with PeterH, this seems a weird way to do something, unless it's a homework assignment.