> Date: Fri, 26 Feb 1999 09:59:39 +0000 > From: Bendix Carstensen <bxc at svs.dk>> When you require 2 digits you expect to find 5.96 printedCorrection, _you_ expect! Very few computer programs do that. You cannot `require' two digits by options(digits=2): ?options says digits: controls the number of digits to print when print- ing numeric values. It is a suggestion only.> as 6.0, i.e. a number somewhere between 5.95 and 6.04999999999999. > This is apparently not always the case for R. > Why does 0 have a special status as trailing digit? > > > options(digits=2) > > x <- c(59.6,59.4) > > x > [1] 60 59 > > x/10 > [1] 6.0 5.9 > > x[1]/10 > [1] 6Because that is how the ASCII C printing functions work. Ultimately print() calls sprintf with a %x.yf format. What happens depends on how that is implemented on your system. S-PLUS has an option nsmall to format to do precisely this, and there was a question asking how to do it on s-news today. I have thought for a while that we need to implement something like this in R: maybe I had better do it.... -- 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 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>>>>> "BDR" == Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:>> Date: Fri, 26 Feb 1999 09:59:39 +0000 From: Bendix Carstensen >> <bxc at svs.dk> >> When you require 2 digits you expect to find 5.96 printed BDR> Correction, _you_ expect! Very few computer programs do that. BDR> You cannot `require' two digits by options(digits=2): ?options BDR> says BDR> digits: controls the number of digits to print when print- ing BDR> numeric values. It is a suggestion only. >> as 6.0, i.e. a number somewhere between 5.95 and 6.04999999999999. >> This is apparently not always the case for R. Why does 0 have a >> special status as trailing digit? >> >> > options(digits=2) > x <- c(59.6,59.4) > x [1] 60 59 > x/10 [1] 6.0 >> 5.9 > x[1]/10 [1] 6 BDR> Because that is how the ASCII C printing functions work. BDR> Ultimately print() calls sprintf with a %x.yf format. What happens BDR> depends on how that is implemented on your system. BDR> S-PLUS has an option nsmall to format to do precisely this, and BDR> there was a question asking how to do it on s-news today. I have BDR> thought for a while that we need to implement something like this BDR> in R: maybe I had better do it.... Is it necessary? In R, we've always been having formatC(.) as an alternative to format(.) allowing more precise formatting specifications. However, maybe I didn't understand what yuo were alluding to.. Martin -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._