[metapost] Metafun: the pi number in double precision
Franck Pastor
franck.pastor at me.com
Sat Jan 25 14:28:40 CET 2014
Le 25 janv. 2014 à 11:20, luigi scarso <luigi.scarso at gmail.com> a écrit :
>
> I see this:
>
> $> cat test.mp
> pi := 3.14159265358979323846;
> show pi;
> end.
>
> $> mpost --version
> MetaPost 1.803 (TeX Live 2013)
> The MetaPost source code in the public domain.
> MetaPost also uses code available under the
> GNU Lesser General Public License (version 3 or later);
> therefore MetaPost executables are covered by the LGPL.
> There is NO warranty.
> For more information about these matters, see the file
> COPYING.LESSER or <http://gnu.org/licenses/lgpl.html>.
> Original author of MetaPost: John Hobby.
> Author of the CWEB MetaPost: Taco Hoekwater.
>
> $> for j in scaled double binary decimal; do echo "%%%%% $j "; mpost -numbersystem=$j test.mp; done
> %%%%% scaled
> This is MetaPost, version 1.803 (kpathsea version 6.1.1)
> (/opt/luatex/standalone-mkiv-new/tex/texmf/metapost/base/mpost.mp (/opt/luatex/standalone-mkiv-new/tex/texmf/metapost/base/plain.mp
> Preloading the plain mem file, version 1.004) ) (./test.mp
>>> 3.14159 )
> Transcript written on test.log.
> %%%%% double
> This is MetaPost, version 1.803 (kpathsea version 6.1.1)
> (/opt/luatex/standalone-mkiv-new/tex/texmf/metapost/base/mpost.mp (/opt/luatex/standalone-mkiv-new/tex/texmf/metapost/base/plain.mp
> Preloading the plain mem file, version 1.004) ) (./test.mp
>>> 3.14159265358979 )
> Transcript written on test.log.
> %%%%% binary
> This is MetaPost, version 1.803 (kpathsea version 6.1.1)
> (/opt/luatex/standalone-mkiv-new/tex/texmf/metapost/base/mpost.mp (/opt/luatex/standalone-mkiv-new/tex/texmf/metapost/base/plain.mp
> Preloading the plain mem file, version 1.004) ) (./test.mp
>>> 3.14159265358979 )
> Transcript written on test.log.
> %%%%% decimal
> This is MetaPost, version 1.803 (kpathsea version 6.1.1)
> (/opt/luatex/standalone-mkiv-new/tex/texmf/metapost/base/mpost.mp (/opt/luatex/standalone-mkiv-new/tex/texmf/metapost/base/plain.mp
> Preloading the plain mem file, version 1.004) ) (./test.mp
>>> 3.14159265358979 )
> Transcript written on test.log.
>
> --
> luigi
Right, but you have entered this pi number yourself, and you ran your test file with the format "plain". I was talking about the pi number as defined in the Metafun format. Here is how I processed:
iMacIntel20-4:~ fp$ mpost --mem=metafun --numbersystem=double
This is MetaPost, version 1.803 (kpathsea version 6.1.1)
**null
(metafun.mp
(/usr/local/texlive/2013/texmf-dist/metapost/context/base/metafun.mpii
(/usr/local/texlive/2013/texmf-dist/metapost/context/base/mp-base.mpii
Preloading the plain mem file, version 0.63)
(/usr/local/texlive/2013/texmf-dist/metapost/context/base/mp-tool.mpii)
(/usr/local/texlive/2013/texmf-dist/metapost/context/base/mp-spec.mpii)
(/usr/local/texlive/2013/texmf-dist/metapost/context/base/mp-core.mpii)
(/usr/local/texlive/2013/texmf-dist/metapost/context/base/mp-page.mpii)
(/usr/local/texlive/2013/texmf-dist/metapost/context/base/mp-text.mpii)
(/usr/local/texlive/2013/texmf-dist/metapost/context/base/mp-txts.mpii)
(/usr/local/texlive/2013/texmf-dist/metapost/context/base/mp-shap.mpii)
(/usr/local/texlive/2013/texmf-dist/metapost/context/base/mp-butt.mpii)
(/usr/local/texlive/2013/texmf-dist/metapost/context/base/mp-char.mpii)
(/usr/local/texlive/2013/texmf-dist/metapost/context/base/mp-step.mpii)
(/usr/local/texlive/2013/texmf-dist/metapost/context/base/mp-grph.mpii)
(/usr/local/texlive/2013/texmf-dist/metapost/context/base/mp-figs.mpii)
(/usr/local/texlive/2013/texmf-dist/metapost/context/base/mp-grid.mpii
(/usr/local/texlive/2013/texmf-dist/metapost/context/base/mp-form.mpii
(/usr/local/texlive/2013/texmf-dist/metapost/base/string.mp)
(/usr/local/texlive/2013/texmf-dist/metapost/base/marith.mp
(/usr/local/texlive/2013/texmf-dist/metapost/base/string.mp))))
(/usr/local/texlive/2013/texmf-dist/metapost/context/base/mp-func.mpii) ) )
(dump occurred when else on line 5 was incomplete)
(/usr/local/texlive/2013/texmf-dist/metapost/misc/null.mp)
*show pi;
>> 3.1415926
I've just looked into the mp-too.mpiv file of my text distribution. The pi number is defined in line 294:
pi := 3.1415926 ; radian := 180/pi ; % 2pi*radian = 360 ;
(There is also a Pi number, equal to this pi, a few lines above).
I guess I only have to define my own pi number like the one you've just used, but maybe it would be useful to change the mp-tool.mpiv and mp-tool.mpii files accordingly?
Thanks
Franck Pastor
More information about the metapost
mailing list