MATLAB: How could numbers be displayed only in 4 digits (also in answer of sprintf)

digitnumberssprintf

Does anyone know how could numbers be displayed only in 4 digits (also in answer of sprintf) [not more than 4)
a=3.78676789728978978978978789
sprintf('%d',a)= 3.786768e+000 % but i dont need this format
sprintf('%f',a)= 3.786768 % this is better but only 4 digits is needed
I need: 3.7867 or 3.786

Best Answer

sprintf('%4.3f',pi)
doc sprintf