[metapost] New number systems compute cyclic path strangely

luigi scarso luigi.scarso at gmail.com
Mon Apr 29 20:11:38 CEST 2024


On Sun, 28 Apr 2024 at 17:21, Toby Thurston <thurston at eml.cc> wrote:

> This recent question on TexSE seems to have uncovered an anomaly in the
> way that MP computes the `arclength` of cyclic paths when using any of the
> new number systems.
>
> https://tex.stackexchange.com/q/716630/15036
>
>
> The poster supplied this example code
>
> beginfig(1);
> path p;
> p = (0,0){up}..{right}(200,100)..{up}(300,400)..cycle;
> len := arclength p;
> s := arctime (2500) of p;
> t := arctime (len+2500) of p;
> draw p;
> show len;% 2799
> show s;% 2.92...
> show t;% 2.67...
> show arctime arclength p of p;
> show numbersystem;
>
> endfig;
> end
>
> With the default number system the value of t is 5.92... as you might
> expect, but with any of the new number systems the value is 2.67.....
>
> The original poster as TeX.SE was using MP 2.02 but I I see this behaviour
> with  MetaPost, version 2.10 (TeX Live 2024).
>
> Toby
> --
> http://tug.org/metapost/


Hm I fear that
 @<Update |arc| and |t_tot| after |do_arc_test| has just returned |t|@>;
implicitly uses the fact that scaled is an integer type, i.e.
set_number_from_div (n1, arc, d1); /* n1 = (arc / d1) */
and
number_add (v1, epsilon_t);       /* v1 = n1+1 */
look suspicious in double mode  ( epsilon_t is not 1 but 2^-52, 1 is unity
)

--
luigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/metapost/attachments/20240429/59e2d86b/attachment.htm>


More information about the metapost mailing list.