From savicky at cs.cas.cz  Thu May 28 09:36:48 2009
From: savicky at cs.cas.cz (Petr Savicky)
Date: Thu, 28 May 2009 09:36:48 +0200
Subject: [Rd] as.numeric(levels(factor(x))) may be a decreasing sequence
In-Reply-To: <18973.42970.826686.173830@cmath-5.math.ethz.ch>
References: <20090523074454.GA17112@cs.cas.cz>
	<18973.42970.826686.173830@cmath-5.math.ethz.ch>
Message-ID: <20090528073648.GA18207@cs.cas.cz>

On Wed, May 27, 2009 at 10:51:38PM +0200, Martin Maechler wrote:
> I have very slightly  modified the changes (to get rid of -Wall
> warnings) and also exported the function as Rf_dropTrailing0(),
> and tested the result with 'make check-all' .

Thank you very much for considering the patch. -Wall indeed requires to add 
parentheses
  warning: suggest parentheses around comparison in operand of &
  warning: suggest parentheses around assignment used as truth value

If there are also other changes, i would like to ask you to make your modification
available, mainly due to a possible further discussion.

Let me also suggest a modification of my original proposal. It contains a cycle
           while (*(replace++) = *(p++)) {
               ;
           }
If the number has no trailing zeros, but contains an exponent, this cycle
shifts the exponent by 0 positions, which means that it copies each of its
characters to itself. This may be eliminated as follows
           if (replace != p) {
               while (*(replace++) = *(p++)) {
                   ;
               }
           }

Petr.



[Rd] as.numeric(levels(factor(x))) may be a decreasing sequence
Petr Savicky