%!TEX pdflatex

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{pgf,pgffor}
\usepackage{xfp}
\usepackage{xstring}
\usepackage{siunitx}
\sisetup{locale=FR}

\begin{document}

\newcommand{\partialbox}[1]{\underline{#1}\raisebox{-1.1pt}{\rule[-2.75pt]{1pt}{12pt}}}

\newcommand\arrondi[2]{
	%variables
	\edef\nivsup{\inteval{#2+1}}
	\edef\nbgauche{\fpeval{floor(#1,#2)}}
	\edef\nbdroite{\fpeval{\nbgauche+10**(-#2)}}
	\edef\nbmilieu{\fpeval{0.5*\nbgauche+0.5*\nbdroite}}
	\StrCut{#1}{.}\PartEnt\PartDec
	\StrChar{\PartDec}{\nivsup}[\nbcoupe]
	\StrSplit{\PartDec}{#2}\PDGauche\DecDroite
	\StrGobbleLeft{\DecDroite}{1}[\PDDroite]
	\begin{tikzpicture}
		\draw[->] (-0.1,0) --(10.2,0);
		\coordinate (A) at (0,0.9) ;
		\coordinate (B) at (10,0.9) ;
		\draw[very thick] (0,-10pt)--(0,10pt) node[above] {\num{\nbgauche}} ;
		\draw[very thick] (10,-10pt)--(10,10pt) node[above] {\num{\nbdroite}} ;
		\foreach \i in {1,2,3,4,6,7,8,9}{\draw[thick,red] (\i,-6pt)--(\i,6pt) ;}
		\draw[thick,blue] (5,8pt)--(5,-8pt) node[below] {\num{\nbmilieu}} ;
		\draw[line width=4pt,purple] ({\nbcoupe},0)--++(1,0);
		\node[draw,rounded corners=.3cm,minimum width=3cm,minimum height=1cm] (J) at (5,2) {\partialbox{\PartEnt,\PDGauche}\hspace{1pt}\colorbox{purple}{\makebox[0em]{\nbcoupe}}\hspace{1pt}\PDDroite} ;
		\coordinate (I) at ({\nbcoupe+0.5},0.1);
		\draw[->,>=latex,dotted,thick] (J) to[out=270,in=90] node[midway,above]{\tiny \texttt{quelque part ici}} (I) ;
		\ifnum\nbcoupe<5
		{\draw[->,>=latex,very thick] (J) to[out=180,in=60] node[midway,above] {\tiny \texttt{plus proche de}} (A);}%
		\else%
		{\draw[->,>=latex,very thick] (J) to[out=0,in=120] node[midway,above] {\tiny \texttt{plus proche de}} (B);}
		\fi
	\end{tikzpicture}
}

\arrondi{15.4467}{1}

\medskip

\verb|\arrondi{36.34889}{2}|

\arrondi{36.34889}{2}

\hrulefill

\medskip

\verb|\arrondi{74.2562}{2}|

\arrondi{74.2562}{2}

\hrulefill

\medskip

\verb|\arrondi{145.123456}{3}|

\arrondi{145.123456}{3}

\hrulefill

\medskip

\verb|\arrondi{15.4862}{1}|

\arrondi{15.4862}{1}

\end{document}