From ripley at stats.ox.ac.uk  Thu Mar 25 06:58:21 2010
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu, 25 Mar 2010 05:58:21 +0000 (GMT)
Subject: [Rd] print(big+small*1i) -> big + 0i
In-Reply-To: <77EB52C6DD32BA4D87471DCD70C8D70002AC3C28@NA-PA-VBE03.na.tibco.com>
References: <77EB52C6DD32BA4D87471DCD70C8D70002AC3C28@NA-PA-VBE03.na.tibco.com>
Message-ID: <alpine.LFD.2.00.1003250549310.31606@gannet.stats.ox.ac.uk>

On Wed, 24 Mar 2010, William Dunlap wrote:

> Should both parts of a complex number be printed
> to the same precision?   The imaginary part of 0
> looks a bit odd when log10(real/imag) >=~ getOption("digits"),
> but I'm not sure it is awful.  Some people might
> expect the same number of significant digits in the
> two parts.

'significant digits' is documented in ?signif and xref-ed in ?print.
So, yes, the are 'printed to the same precision' for the definition 
given of 'precision'.  (One can argue that precision is relative to 
the modulus, but this definition is a close approximation.)

>From the NEWS for 2.4.0:

     o	Printing of complex numbers could misbehave when one of the
 	parts was large (so scientific notation was used) and the
 	other was so much smaller that it had no significant digits
 	and should have been printed as zero (e.g. 1e80+3e44i).

and 2.2.0

     o	signif() on complex numbers now rounds jointly to give the
 	requested number of digits in the larger component, not
 	independently for each component.


>
>> 1e7+4i
> [1] 10000000+0i
>> 1e7+5i
> [1] 10000000+0i
>> 1e10 + 1000i
> [1] 1e+10+0e+00i
>> getOption("digits")
> [1] 7

...

-- 
Brian D. Ripley,                  ripley at 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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] print(big+small*1i) -> big + 0i
Prof Brian Ripley