## #. y (Base 2)

Returns the corresponding number of a binary numeral, given as a Boolean list.

```   #. 1 0 1 0 1
21
#. 1 0 1 0
10
#. 1 1 1 1 1
31
#. 1 1 1
7```

Generalizes to a Boolean matrix, which gets treated as a list of binary numerals

```   ] z=: > 1 0 1 0 1 ; 0 1 0 1 0 ; 1 1 1 1 1 ; 0 0 1 1 1
1 0 1 0 1
0 1 0 1 0
1 1 1 1 1
0 0 1 1 1
#. z
21 10 31 7```

### Common uses

1. Binary to decimal conversion

```   z=: '.....X.X'   NB. sample binary form
'X'=z
0 0 0 0 0 1 0 1
#. 'X'=z
5```

## x #. y (Base)

Generalizes action of (#.y) to bases other than 2 (including mixed bases).

• If x is an atom (a scalar integer), it is reshaped to the shape of y.

```     #. 1 0 1 0 1   NB. base-2 numeral --> number
21
2 #. 1 0 1 0 1   NB. ditto, but base (=2) is explicitly specified
21
10 #. 1 0 1 0 1  NB. base-10 numeral --> number
10101
10 #. 9 0 8 0 1
90801```

### Common uses

1. Convert list of decimal digits to number

```   numberOf=: 10 & #.
numberOf 9 0 8 0 1
90801```

2. Convert time-interval in (hours,minutes,seconds) to seconds

```   seconds=: 24 60 60 & #.
seconds 23 59 59
86399
*/24 60 60
86400```

3. Evaluate a polynomial in y for given y, given the coefficients: (a)

• if (a) are for ascending powers of y, then use (#.&|.) to reverse (a) first.

Example: sum the exponential series to 10 terms, to approximate the value of exp y

```   exp=: ^
] a=: % !i.10   NB. The first 10 coefficients of the exponential series
1 1 0.5 0.166667 0.0416667 0.00833333 0.00138889 0.000198413 2.48016e_5 2.75573e_6
1 (#.&|.) a
2.71828
exp 1
2.71828
2 (#.&|.) a
7.38871
exp 2
7.38906```

Can also use p. to evaluate the polynomial with coefficients (a)

```   a p. 1
2.71828
a p. 2
7.38871```