[pstricks] Testing a number

Herbert Voss Herbert.Voss at FU-Berlin.DE
Wed Jun 18 09:50:14 CEST 2008


John Smith schrieb:
>> giv an example in which case do you need such a test.

 > I want the macro to return numbers as follows.
 > \test{0} -> 0\test{1.234} -> 1\test{-1.234} -> -1
 > I need to know the sign of the number because it influences
 > whether I draw a vector (if number is not equal to zero) and
 > in which direction it points. Thanks.

\listfiles

\documentclass{article}
\usepackage{pstricks}
\makeatletter
\def\test#1{\expandafter\test at i#1..\@nil}
\def\test at i#1.#2.\@nil{#1}
\makeatother

\begin{document}

\begin{pspicture}[showgrid=true](0,-1)(5,5)
\psline(5,\test{0.3456})(\test{3.12234},\test{4.4},\test{5})(0,\test{-1.2345})
\end{pspicture}

\end{document}

Herbert



More information about the PSTricks mailing list