fractal.generator wrote:
I want to print out the value of \textwidth, for example, in a certain precision.
Are there the ceil and floor functions available in latex to specify the precision?
No, they aren't. The printlen package only provides the \rndprintlength command that just prints the integer part. Anyway, coming back to the code I gave you in other thread, with a slight change, you can round lengths to any decimal digit:
Code: Select all
\documentclass{article}
\usepackage{printlen}
\usepackage{fp}
\newlength{\TOarg} \newlength{\TOunit}
\makeatletter
\newcommand\TOop[2]{\setlength{\TOarg}{#2}%
\FPdiv\TOres{\strip@pt\TOarg}{\strip@pt\TOunit}\FPround\TOres\TOres{#1}}
\makeatother
\newcommand{\TOspace}{\,}
\newcommand\TOmm[2][2]{\setlength{\TOunit}{1mm}\TOop{#1}{#2}%
\TOres\TOspace\ifmmode\mathrm{mm}\else mm\fi}
% If needed, define \TOin, \TOcm, \TOem... analogously, replacing mm by in, cm, em...
\begin{document}
\uselengthunit{mm}
The \verb|\textwidth| is \printlength{\textwidth}, that is, about \rndprintlength{\textwidth}.
The \verb|\textwidth| is \TOmm[5]{\textwidth}, that is, about \TOmm[0]{\textwidth},
or \TOmm[1]{\textwidth}, or \TOmm{\textwidth}, or \TOmm[3]{\textwidth}, or \TOmm[4]{\textwidth}.
\bigskip
\setlength{\unitlength}{1mm}
\noindent
Test of exactness:\\
\verb|\unitlength|= \printlength{\unitlength} \\
\verb|\unitlength|= \TOmm[5]{\unitlength}
\end{document}
If you replace \FPround by \FPtrunc, you get the floor function.