The PR #15 is about a \texdimendivide{dim1}{dim2} doing an approximate computation of the mathematical dim1/dim2, to the extent possible in (e)TeX base handling of input and output of dimensions. Indeed current (0.99) \texdimenwithunit{dim1}{dim2} gives an ouput R is guaranteed to let R<dim2> be parsed by TeX into something close to dim1, but the way it does this lets this R diverge somewhat from the mathematical dim1/dim2, and very noticeably for small dimensions.
Indeed as TeX truncates when it multiplies, this R, whose specification is that R<dim2> should be near <dim1>, will by force usually be larger than the mathematical dim1/dim2 ratio.
In the current implementation the divergence is very noticeable for small dimensions. For example:
At first one is comforted by the fact that 0.66666 indeed would not work:
*\message{\number\dimexpr0.66666\dimexpr3sp}
1
but the naive expected value 0.66667 does work:
*\message{\number\dimexpr0.66667\dimexpr3sp}
2
This is indication that perhaps the handling of \texdimenwithdivide{dim1}{dim2} is sub-optimal, particularly in the dim2<1pt branch. The chosen formula does work but isn't it a bit too secure?
the condition on N is that it should be at least ceil(U * psi) and at most ceil((U+1) * psi) -1.
No wonder then that round(U * psi) will not always work: if it rounds strictly down, we are doomed.
What about the M = round((U+0.5)*psi)̀ approach, will it work? (psi = 1/phi > 1).
and we use currently the round((U+0.5)*psi)̀ formula in this dim2<1pt case. But the closest to round(U * psi) (which is best we can do to approximate the mathematical dim1/dim2 is ceil(U*psi).
I propose \texdimenwithunit{dim1}{dim2} should implement, for dim2<1pt, the ceil(U*psi) formula so as to reduce the divergence from exact mathematical ratio dim1/dim2. This will make #15 unneeded.
The PR #15 is about a
\texdimendivide{dim1}{dim2}
doing an approximate computation of the mathematicaldim1/dim2
, to the extent possible in (e)TeX base handling of input and output of dimensions. Indeed current (0.99
)\texdimenwithunit{dim1}{dim2}
gives an ouputR
is guaranteed to letR<dim2>
be parsed by TeX into something close todim1
, but the way it does this lets thisR
diverge somewhat from the mathematicaldim1/dim2
, and very noticeably for small dimensions.Indeed as TeX truncates when it multiplies, this
R
, whose specification is thatR<dim2>
should be near<dim1>
, will by force usually be larger than the mathematicaldim1/dim2
ratio.In the current implementation the divergence is very noticeable for small dimensions. For example:
At first one is comforted by the fact that
0.66666
indeed would not work:but the naive expected value
0.66667
does work:This is indication that perhaps the handling of
\texdimenwithdivide{dim1}{dim2}
is sub-optimal, particularly in thedim2<1pt
branch. The chosen formula does work but isn't it a bit too secure?As explained in https://github.com/jfbu/texdimens/issues/2#issuecomment-957921157:
and we use currently the
round((U+0.5)*psi)̀
formula in thisdim2<1pt
case. But the closest toround(U * psi)
(which is best we can do to approximate the mathematicaldim1/dim2
isceil(U*psi)
.I propose
\texdimenwithunit{dim1}{dim2}
should implement, fordim2<1pt
, theceil(U*psi)
formula so as to reduce the divergence from exact mathematical ratiodim1/dim2
. This will make #15 unneeded.