public static BigDecimal bitStringToBigDecimal ( String bitStr ) {
  BigDecimal sum = new BigDecimal ( "0" ) ;
  BigDecimal base = new BigDecimal ( 2 ) ;
  BigDecimal temp ;
  for ( int i = 0 ;
  i < bitStr . length ( ) ;
  i ++ ) {
    if ( bitStr . charAt ( i ) == '1' ) {
      int exponent = bitStr . length ( ) - 1 - i ;
      temp = base . pow ( exponent ) ;
      sum = sum . add ( temp ) ;
    }
  }
  return sum ;
}

public static BigDecimal bitStringToBigDecimal ( String bitStr ) { BigDecimal sum = new BigDecimal ( "0" ) ; BigDecimal base = new BigDecimal ( 2 ) ; BigDecimal temp ; for ( int i = 0 ; i < bitStr . length ( ) ; i ++ ) { if ( bitStr . charAt ( i ) == '1' ) { int exponent = bitStr . length ( ) - 1 - i ; temp = base . pow ( exponent ) ; sum = sum . add ( temp ) ; } } return sum ; }
(method_declaration (modifiers) type: (type_identifier) name: (identifier) parameters: (formal_parameters (formal_parameter type: (type_identifier) name: (identifier))) body: (block (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (string_literal))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier) value: (object_creation_expression type: (type_identifier) arguments: (argument_list (decimal_integer_literal))))) (local_variable_declaration type: (type_identifier) declarator: (variable_declarator name: (identifier))) (for_statement init: (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (decimal_integer_literal))) condition: (binary_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list))) update: (update_expression (identifier)) body: (block (if_statement condition: (parenthesized_expression (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))) right: (character_literal))) consequence: (block (local_variable_declaration type: (integral_type) declarator: (variable_declarator name: (identifier) value: (binary_expression left: (binary_expression left: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list)) right: (decimal_integer_literal)) right: (identifier)))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))) (expression_statement (assignment_expression left: (identifier) right: (method_invocation object: (identifier) name: (identifier) arguments: (argument_list (identifier))))))))) (return_statement (identifier))))