# Why we used \number in Latex?

Here is my code:

\documentclass{article}

\makeatletter
\def\Printdimen#1#2{\strip@pt \dimexpr #2 *65526 /\number\dimexpr 1#1}
\makeatother

\begin{document}

\Printdimen{mm}{\hsize} mm
\end{document}

• @DavidCarlisle Yeah , because i am confused about that Apr 28 '15 at 16:00
• @egreg but after / i used \dimexpr 1#1 Apr 28 '15 at 16:04
• But just asking the same question repeatedly in multiple question sand in chat gives the impression that you ignore the answers. Apr 28 '15 at 16:22
• @enadulshaheen We've already pointed out that this is not really the sort of code that one reads to learn LaTeX. Even if you aim to learn to program plain TeX you should pick up some basics first. Apr 28 '15 at 16:55

The macro \strip@pt wants after it a dimension register; it will remove the final pt after the extracted value.

In e-TeX, \dimexpr behaves as an “unnamed” dimension register, so it's good after \strip@pt. According to the syntax rules of \dimexpr, a dimension (implicit or explicit) inside it can be followed by * or / to denote multiplication or (rounded) division. However the multiplier/divisor must be an integer.

So \dimexpr 3pt/2 is valid, but \dimexpr3pt/1.5 is not.

A dimension register appearing in a context where TeX expects an integer will be coerced to it using the value in scaled points; 65536 scaled points are 1pt, which is the reason for the 65536 multiplier.

Thus \number is not really necessary and

\makeatletter
\def\Printdimen#1#2{\strip@pt\dimexpr (#2) * 65536 / \dimexpr 1#1\relax\relax}
\makeatother


is good as well. It's better to add the two \relax that end the \dimexpr expression.

• perfect answer man . I got it what i need. Thanks Apr 28 '15 at 16:14
• I would add parentheses around #2, then this argument can be any expression understood by \dimexpr without invalidating the multiplication. Apr 28 '15 at 17:39
• @HeikoOberdiek Good idea! Apr 28 '15 at 17:40