[pstricks] Testing a number
John Smith
chessfan123 at hotmail.com
Wed Jun 18 12:26:43 CEST 2008
To answer my own question, this works.
\def\test#1{\FPifzero{#1} 0 \else \testp{#1} \fi}\def\testp#1{\FPifpos{#1} 1 \else -1 \fi}It looks like FP has trouble with nested tests.
From: chessfan123 at hotmail.comTo: pstricks at tug.orgDate: Wed, 18 Jun 2008 07:19:21 +0000Subject: Re: [pstricks] Testing a number
Herbert> Date: Wed, 18 Jun 2008 08:47:23 +0200> From: Herbert.Voss at FU-Berlin.DE> To: pstricks at tug.org> Subject: Re: [pstricks] Testing a number> > John Smith schrieb:> > Is there a way to test is a number is zero, positive or negative? I tried this using the FP package as follows.> > > > \def\test#1{\FPifzero{#1} 0 \else \FPifpos{#1} 1 \else -1 \fi \fi}> > > > It works if the number is positive or negative but gives a Tex error about an extra \fi if the input is zero.> > 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.
Hotmail on your mobile. Never miss another e-mail with
_________________________________________________________________
Never miss another e-mail with Hotmail on your mobile.
http://www.livelife.ninemsn.com.au/article.aspx?id=343869
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://tug.org/pipermail/pstricks/attachments/20080618/5986bd18/attachment.html
More information about the PSTricks
mailing list