[Tex/LaTex] Rounding up decimal number using LaTeX 3

calculationsexpl3

I would like to use LaTeX 3 to round up decimal numbers; I want something like the following: If I type

\RoundingUpFunction{2.7}

it should return

3

as output.

Unfortunately, I haven't taken the time to learn the LaTeX 3 syntax yet, so if someone will show me how to define such a function (or tell me what it is if it already exists), I will much appreciate it.

Update

If I try to use Marco Daniel's answer in the following way, it still doesn't work:

\documentclass{article}

\usepackage{pst-optic,pstricks-add}
\usepackage{xparse}

\newcommand*\Lens[1][]{%
  \psclip{%
    \psframe[linestyle=none](-\horizontal,-\vertical)(\horizontal,\vertical)
  }
  \rput(0,0){\lensSPH[#1]}
  \endpsclip
}

\ExplSyntaxOn
\NewDocumentCommand {\RoundUp} { m }
 {
  \fp_eval:n { round+(#1) }
 }
\ExplSyntaxOff

\begin{document}

\begin{figure}
\def\horizontal{1}
\def\vertical{1.7}
 \centering
  \begin{pspicture}[showgrid](-\RoundUp{\horizontal},-\RoundUp{\vertical})%
                             ( \RoundUp{\horizontal}, \RoundUp{\vertical})
   \Lens[
     lensType=CVG,
     lensWidth=1,
     lensColor=BleuVerre,
     drawing=false
   ]
  \end{pspicture}
\end{figure}

\end{document}

with the error message

! Undefined control sequence.
<argument> \LaTeX3 error: 
                           Unknown fp word a.
l.28 ...RoundUp{\horizontal}, \RoundUp{\vertical})

Best Answer

If you want to use LaTeX3 you can use ceil:

\documentclass{article}

\usepackage{xparse}
\ExplSyntaxOn
\NewDocumentCommand {\RoundingUpFunction} { m }
 {
  \fp_eval:n { ceil(#1) }
 }
\ExplSyntaxOff


\begin{document}
\RoundingUpFunction{1.7}%leads to 2

\RoundingUpFunction{1.2}%leads to 2

\RoundingUpFunction{1}%leads to 1

\end{document}

Related to your update use \DeclareExpandableDocumentCommand instead of \NewDocumentCommand

Related Question