LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

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

Print Reply
Content-Transfer-Encoding:
8bit
Sender:
Mailing list for the LaTeX3 project <[log in to unmask]>
Subject:
From:
Jonathan Sauer <[log in to unmask]>
Date:
Thu, 8 Nov 2007 09:30:06 +0100
Content-Type:
text/plain; charset="us-ascii"
MIME-Version:
1.0
Reply-To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Parts/Attachments:
text/plain (30 lines)
Hello,

I hope this is the right place for this.

Macro \int_div_truncate_raw:nn is defined in file l3int as:

\def_new:Npn \int_div_truncate_raw:nn #1#2 {
  \int_eval:n{ (2*#1 - #2) / (2* #2) }
}

If #1 is zero and #2 is two, this macro does not expand to zero,
as one would expect (0 / 2 = 0), but to -1 (since eTeX rounds
negative numbers by negating them, rounding the positive number
and negating the result. See function "quotient" in etex.ch).

Also, if #2 is an expression (i.e. 1+1), the calculation is not
performed correctly, since #2 (and #1) is not surrounded by ( and ).
(I am not sure if this can happen, or if the parameters are always
evaluated beforehand)

In my code, I use (to divide #1 by #2):

\numexpr((((#1)+((#2)/2))/(#2))-1)\relax

This seems to work better.


HTH,
Jonathan

ATOM RSS1 RSS2