Q:

lower bound upper bound giving same results

I'm trying to find the nearest value in an sorted array, but both upper_bound and lower_bound are giving the highest value.
float abc[] = {1,3,4,5,6,7,8,9};

float *a  = lower_bound(abc, abc+8, 3.2);
cout<< *a;

return 0;

A:

*a will be 4 in both cases, as the value pointed to by a would be 3.2 if that was inserted correctly into the container.
lower_bound and upper_bound will return the same iterator if the value passed is not present in the container, which is the case here.
The iterator returned by lower_bound is defined to be the lowest position where the element passed could reside it was in the container, higher_bound returns the highest position. They do not return anything related to the closest element present in the array. 
In order to find the closest element, you know that the dereferenced result of lower_bound is greater than or equal to the value passed. The value before that, if any, must be less. You can make use of this in order to arrive at the closest value.

