# How are dimensions converted in multiplication and division?

In the TeXbook it is said (page 118):

Multiplication and division are possible too, but only by integers. ... Dimension values are integer multiples of sp (scaled points).

Example 1. Result is 25pt minus -150pt. Why is the multiplicand converted to the same dimension as the multiplier?

\dimen1=25pt
\skip2=1sp minus -6sp
\multiply\skip2 by \dimen1
\showthe\skip2

> 25.0pt minus -150.0pt


Example 2. The result is 25sp minus -150sp. Everything looks good.

\dimen1=25sp
\skip2=1sp minus -6sp
\multiply\skip2 by \dimen1
\showthe\skip2

> 0.00038pt minus -0.00229pt


Example 3. The result is 25sp minus -150sp. Why is the multiplier converted to the same dimension as the multiplicand?

\count1=25
\skip2=1sp minus -6sp
\multiply\skip2 by \count1
\showthe\skip2

> 0.00038pt minus -0.00229pt

• @egreg: I think they are in the same category in TeXbook. Aren't they anologous? – Igor Liferenko Sep 5 '15 at 9:37

## 1 Answer

There is a convention that even register (except count) numbers smaller than ten are free registers for local assignments, whereas odd numbers should only be used for global assignments. Mixing local and global assignments can cause memory trouble. Therefore I have multiplied the register numbers by two to get register numbers for local assignments. The first ten count registers have a special meaning (page number, ...). A free count register for local assignments is count register 255 (\dimen@).

TeX stores length values as integer numbers with implicit unit sp. 216 sp are 1 pt. When TeX expects a number and gets a length value, then this integer number is used.

Commented examples:

Example 1:

\dimen2=25pt
% 25pt = 25 * 65536sp = 1638400sp
\showthe\numexpr\dimen2\relax % \edef\x{\number\dimen2}\show\x
> 1638400

\skip4=1sp minus -6sp
\multiply\skip4 by \dimen2
% (1sp minus -6sp) * 1638400 = 1638400sp minus -9830400sp
% = 25pt minus -150pt
\showthe\skip4

> 25.0pt minus -150.0pt


Example 2:

\dimen2=25sp
\skip4=1sp minus -6sp
\multiply\skip4 by \dimen2
% (1sp minus -6sp) * 25 = 25sp minus -150sp
\showthe\skip4

> 0.00038pt minus -0.00229pt


Example 3:

\count255=25
\skip4=1sp minus -6sp
\multiply\skip4 by \count255
% (1sp minus -6sp) * 25 = 25sp minus -150sp
\showthe\skip4

> 0.00038pt minus -0.00229pt