[metapost] Units unaccuracy with numbersystem set to double
Franck Pastor
franck.pastor at mac.com
Thu Apr 3 15:18:06 CEST 2014
Le 2 avr. 2014 à 16:39, Nelson H. F. Beebe a écrit :
> Akira Kakuto <kakuto at fuk.kindai.ac.jp> writes today:
>
>>> ...
>>> MetaPost 1.900 shows
>>>
>>> *show cm;
>>>>> 28.346450000000001
>>>
>>> Note that MetaPost does not calculate it from an exact formula.
>>> It simply prints the value defined in plain.mp: cm=28.34645;
>>> ...
>
> A more accurate conversion from PostScript big points to cm is this:
>
> hocd128> 72 / 2.54
> 28.346_456_692_913_385_826_771_653_543_307_09
>
> Now that Metapost supplies arithmetic of higher precision, perhaps
> input files and source code should be examined for truncated
> floating-point constants, and those constants replaced by expressions,
> such as the exact 72 / 2.54 above, that could then be evaluated at run
> time in the prevailing precision, which might be higher than that in
> classic METAFONT.
>
It seems it is s unfortunately more complicated than that. With the default arithmetics of MetaPost, 72/2.54 gives a result noticeably less accurate than the constant value of "cm" to be found in plain.mp. For comparison:
*show 72/2.54;
>> 28.34653
*show cm;
>> 28.34645
It seems thus that keeping "cm" and the other units as predefined constants (with a precision as high as possible though) would be safer.
Again, I'm not sure of myself since I don't know much about this subject. However I find it quite interesting to learn as much as possible about it.
Best regards,
Franck Pastor
More information about the metapost
mailing list