**Q:** I'm looking for a more elegant way to get the closest match of a numerical from an array.  

I may have over-complicated things here

Input
-----

```
## A given array A where to search in
$a = (16/10),(16/9),(4/3),(5/4),(21/10),(21/9)  

## A given value B which should be searched for in array A (closest match)
$b = 16/11

```

Desired output
--------------

```
"Closest value to 16/11 is 4/3"

```

My current code to solve the problem
------------------------------------

```
## New array C for the differences of array A - B
$c = $a | %{  [math]::abs($_ - $b) } 

## Measure array C to get lowest value D
$d = $c | measure -Minimum

## Get position E of value D in array C
$e = [array]::IndexOf($c, $d.minimum)

## Position E correlates to array A
echo "Closest value to $b is $($a[$e])

```

### Remarks

* It don't has to be an array if a hash table or something else suits better
* My current code outputs decimals like `1.33333` instead of fractions `4/3`. It would be nice to output the fraction
* Short code is always better