Re: [Rd] printing of complex numbers in R-alpha

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 22 Sep 2006 - 10:52:50 GMT

On Thu, 21 Sep 2006, Robin Hankin wrote:

> Hello
>
> got it:
>
> o The printing of complex numbers has changed, handling numbers
> as a whole rather than in two parts. So both real and
> imaginary parts are shown to the same accuracy, with the
> 'digits' parameter referring to the accuracy of the larger
> component, and both components are shown in fixed or
> scientific notation (unless one is entirely zero when it is
> always shown in fixed notation).
>
> [this from the NEWS of R-2.2.0]
>
> I'm struggling to reconcile the final clause of this with:
>
>
>> 1e100 + 1i
> [1] 1e+100+1i
>> 1e100 + 1e-100i
> [1] 1e+100+0i
>
>
> in both of these cases, the real component is shown in scientific
> notation and the imaginary component isn't.
>
> I'm finding the following example confusing too:
>
>> 1e100 + pi*1i*10^(c(-100,0,1,40,100))
> [1] 1e+100+3.1416e-100i 1e+100+ 3.1416e+00i 1e+100+ 3.1416e+01i
> [4] 1e+100+ 3.1416e+40i 1e+100+3.1416e+100i

Yes, there is a bug here, but I think only for cases where what is printed should be zero, that is for complex numbers with very different magnitudes of real and imaginary parts. A better version would be

> 1e100 + 1i

[1] 1e+100+0e+00i
> 1e100 + 1e-100i

[1] 1e+100+0e+00i
> 1e100 + pi*1i*10^(c(-100,0,1,40,100))
[1] 1e+100+ 0.000000e+00i 1e+100+ 0.000000e+00i 1e+100+ 0.000000e+00i [4] 1e+100+ 0.000000e+00i 1e+100+3.141593e+100i
> 1e50 + c(0, 1, 1e48)*1i

[1] 1e+50+0e+00i 1e+50+0e+00i 1e+50+1e+48i
> 1e50 + pi^-(1:5)*1e46*1i

[1] 1e+50+3.2e+45i 1e+50+1.0e+45i 1e+50+3.2e+44i 1e+50+1.0e+44i 1e+50+0.0e+00i

which is what R-devel now gives.

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

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri Sep 22 20:56:56 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 22 Sep 2006 - 13:30:14 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.