Prof Brian Ripley wrote: > I think your subject line should read 'Excel bug'. From the R help > for round() > > Note that for rounding off a 5, the IEC 60559 standard is expected > to be used, '_go to the even digit_'. > > In case you did not recognize it, IEC 60559 is an international > standard: Excel is not. > > R is Open Source and so you can modify it to emulate the bugs in other > software: that is not one of the aims of its developers so please > don't expect us to do so for you. > > It is rare for round() to be called explicitly in R code: rounding is > usually going on inside print routines.
besides noting that r is as much an international standard as excel, here's an example of how the otherwise buggy sprintf (less so now, thanks to martin's recent fixes) and other print routines let excel bugs sneak into r: (x = c(0.15, 0.25, 0.35, 0.45, 0.55, 0.65)) round(x, 1) print(x, 1) sprintf('%.1f', x) ?print and ?sprintf do not say anything about how rounding is done, but given the above strong statement about standards, one would expect that the ties-to-even mode is used. apparently, round (the function) and the print routines (sprintf and print) either operate in different rounding modes, or read the input (the internal representation of numbers) differently. not so surprisingly, sprintf in r reproduces the behaviour of sprintf in c. but would it be a good idea to blame c for excel bugs in r? vQ ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.