6

I've got some macros storing information about various dimensions. When I start dividing by dimensions, though, I'm getting answers that don't make sense.

\documentclass{article}
\usepackage[landscape]{geometry}
\makeatletter
\def\aetopmargin{0.85in}%%
\def\aebotmargin{0.5in}%%
\def\aeworkspacetopsep{4ex}
\def\aeworkspacerulesep{0.65cm}
\edef\aeworkspaceheight{\dimexpr\paperheight-\aeworkspacetopsep-\aetopmargin-\aebotmargin}
\typeout{==>Work space height===>\strip@pt\dimexpr\aeworkspaceheight}
\typeout{==>Work space rule: ===>\strip@pt\dimexpr\aeworkspacerulesep}
\typeout{==>Their quotient is===>\strip@pt\dimexpr \dimexpr\aeworkspaceheight\relax / \dimexpr\aeworkspacerulesep\relax \relax}
\makeatother
\pagestyle{empty}
\begin{document}
empty
\end{document}

When I run this I get the following output on the terminal:

==>Work space height===>499.5079
==>Work space rule: ===>18.49411
==>Their quotient is===>0.00041

Shouldn't I be getting something more like

==>Their quotient is===>27.00902...
A.Ellett
  • 50,533
  • Nevermind now I got what you mean. Sorry – percusse Apr 10 '14 at 20:28
  • rather than defining a macro, try using \newdimen\xxx \setdimen\xxx0.85in etc. – barbara beeton Apr 10 '14 at 20:29
  • @barbarabeeton I could do that, but it's actually easier for the current document if I don't have to work with dimensions for these values. On the surface, I'm sure that sounds absurd. But I designed the document around the macros because for the most part I'm actually not using these as dimensions. – A.Ellett Apr 10 '14 at 20:32
  • pgfmath reports the correct values so it must be an ambiguous interpretation of etex – percusse Apr 10 '14 at 20:34
  • @percusse I just tried pgfmath (because you mentioned it) and it gave me an "Arithmetic overflow" error. This is what I fed it: \pgfmathparse{\aeworkspaceheight/\aeworkspacerulesep} – A.Ellett Apr 10 '14 at 20:37
  • @percusse When I write \pgfmathparse{\dimexpr\aeworkspaceheight\relax/\dimexpr\aeworkspacerulesep\relax} I get the same erroneous 0.00041 – A.Ellett Apr 10 '14 at 20:40
  • 1
    It needs parenthesis around them to your previous comment :) – percusse Apr 10 '14 at 20:41
  • @percusse. OK that works. But why does \pgfmathparse{\dimexpr\aeworkspaceheight\relax/\dimexpr\aeworkspacerulesep\rela‌​x} still not work correctly? – A.Ellett Apr 10 '14 at 20:43
  • If we find it out that would be the answer to your question too :) I think it terminates parsing the whole number for some reason. And I'm out of votes :| – percusse Apr 10 '14 at 20:44
  • @percusse Fortunately this is all coming up in a context where I'm perfectly happy using pgfmath. So I've got a solution, but not an answer. :) Thanks. – A.Ellett Apr 10 '14 at 20:46

1 Answers1

8

You can only divide by a length number , returning a length using etex / you can not divide two lengths to get a number. So if you divide by a length it is cast to a number by taking the length as an integer number of sp that number is a lot bigger than you intended, so the quotient is rather small.

David Carlisle
  • 757,742