Graphics, Figures & TablesPSTricks | Floating Point Calculations

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

PSTricks | Floating Point Calculations

Post by svend_tveskaeg »

Hi all.

Consider the following MWE:

Code: Select all

\documentclass{article}
\usepackage{pstricks-add}

\begin{document}
\def\PI{3.1415926535897932384626}
\def\minimum{0}
\def\maximum{10}
\pstFPsub\length{\maximum}{\minimum}
\pstFPsub\constA{\PI}{2}
\pstFPdiv\constB{\constA}{2}
\pstFPmul\square{\length}{\length}
\pstFPmul\area{\constB}{\square}
\area
\end{document}
Is there no easier way of calculating the value of \area using the \pstFP syntax?

Thank you in advance!
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

CrazyHorse
Posts: 351
Joined: Sat Aug 02, 2008 8:47 am

PSTricks | Floating Point Calculations

Post by CrazyHorse »

svend_tveskaeg wrote: Is there no easier way of calculating the value of \area using the \pstFP syntax?
do you want it only to print?

Code: Select all

\documentclass{article}
\usepackage{pst-tools}

\begin{document}
\def\minimum{0 }
\def\maximum{10 }
\psPrintValue{\maximum \minimum sub dup mul Pi 2 div 1 sub mul } 

\psPrintValue[algebraic]{0,(\maximum-\minimum)^2*(Pi/2-1)}%0 is dummy value for x

\end{document}
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

PSTricks | Floating Point Calculations

Post by svend_tveskaeg »

Very nice! I did not even knew pst-tools existed. :shock:

This particular value is for printing only but others are not.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
Post Reply