LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Qing Lee <[log in to unmask]>
Wed, 7 May 2014 10:10:51 +0800
text/plain (62 lines)
On 2014-05-05 at 16:01:02 +0800 GMT, Joseph Wright wrote:
> On 05/05/2014 00:08, Heiko Oberdiek wrote:
>> Hello,
>>
>> macro \__dim_strip_bp:n is defined in l3skip.dtx the following way:
>>
>>    \cs_new:Npn \__dim_strip_bp:n #1
>>      { \__dim_strip_pt:n { 0.996 26 \__dim_eval:w #1 \__dim_eval_end: } }
>>
>> The calculation from bp to bp is essentially:
>>
>>      \dimexpr 0.99626\dimexpr #1\relax\relax
>>
>> Of course, there will always be rounding errors, but the code
>> can be improved by a scaling operation inside e-TeX's \dimexpr,
>> from "The e-TeX manual":
>>
>> | The arithmetic operations are performed individually, except
>> | for ‘scaling’ operations (a multiplication immediately followed
>> | by a division) which are performed as one combined operation
>> | with a 64-bit product as intermediate value.
>>
>> Improved version with higher precision:
>>
>>    \cs_new:Npn \__dim_strip_bp:n #1
>>      {
>>        \__dim_strip_pt:n
>>          {
>>            \__dim_eval:w ( #1 ) * 800 / 803 \__dim_eval_end:
>>          }
>>      }
>>
>> * 800/803 is the integer fraction for 72/72.27
>> * The parentheses around #1 ensure, that #1 is
>>    calculated first.
>>
>> Yours sincerely
>>    Heiko Oberdiek
>>
>
> Altered in the trunk: will feature in the next release.
> --
> Joseph Wright
>

Hello,

The new definition will be broken if its argument contains additional units. E.g.,

     \__dim_strip_bp:n { 1 bp pt }

So I think the proper definition is similarly:

     \cs_new:Npn \@@_strip_bp:n #1
       {
         \@@_strip_pt:n
           { \@@_strip_pt:n {#1} pt * 800 / 803 \@@_eval_end: }
       }

Best Regards,
Qing Lee

ATOM RSS1 RSS2