s-news
[Top] [All Lists]

Re: [S] decimal points in Splus v5

To: Peter Perkins <peter@caliban.ucsd.edu>
Subject: Re: [S] decimal points in Splus v5
From: Prof Brian D Ripley <ripley@stats.ox.ac.uk>
Date: Wed, 30 Jun 1999 07:37:43 +0100 (BST)
Cc: S-News <s-news@wubios.wustl.edu>
In-reply-to: <377942E4.E0C47A60@caliban.ucsd.edu>
Sender: owner-s-news@wubios.wustl.edu
On Tue, 29 Jun 1999, Peter Perkins wrote:

> can anyone point me to documentation about how/why the new release of S
> deals with decimal points in numbers that don't "need them"? that is, in
> S-Plus v5.1, the expression 
> 
>    function() c(1, 1., 1.0, 1.1)
> 
> returns
> 
>    function()
>    c(1, 1., 1., 1.1)
> 
> where v3.4 used to return
> 
>    function()
>    c(1, 1, 1, 1.1)
> 
> should i care? i first noticed this while using convertOldLibrary(), but
> i don't see mention of it anywhere in the green book or the manuals.

There are two things possibly going on here:

(1) S-PLUS 5.x can make much more use of integer storage mode (indeed, has
a vector class called "integer")

(2) How expressions are deparsed for human consumption.

Now a vector has only one mode, so 
> class(c(1, 1., 1., 1.1))
[1] "numeric"

shows this is of double storage mode, now known as "numeric". Had you used
c(1,3,4) it would have been "integer".

However, in your example the expression has not been evaluated, so you are
seeing the result of deparse of parse of "c(1, 1., 1.0, 1.1)". And yes,
it deparses differently. I think this is usually an advantage in
distinguishing the integer "1" and numeric "1.".  Sometimes this is a
bit wierd, as in

summary(snip.tree(fgl.tr, nodes=c(11, 53, 105, 108, 31)))

gives

snip.tree(tree = fgl.tr, nodes = c(11., 10., 15., 108., 109., 12., 26.))
...

as there the numbers are all integers.


Let us be clear: this has nothing to do with `how/why the new release of S
deals with decimal points in numbers that don't "need them"?' S always
handles numbers to its full internal precision, and this is not a
_printing_ issue either. Deparsing is only seen rarely, often in generating
labels, and in printing calls.


-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu.  To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message:  unsubscribe s-news

<Prev in Thread] Current Thread [Next in Thread>