[Rd] Flag '#' in sprintf() gives an error in R v2.9.0 devel

From: Henrik Bengtsson <hb_at_stat.berkeley.edu>
Date: Mon, 02 Feb 2009 11:34:37 -0800


Hi,

in R v2.8.1 patched (2008-12-22 r47296) the following works:

> sprintf("%#x", 1)

[1] "0x1"

whereas in R v2.9.0 devel (2009-01-08 r47515) it gives:

> sprintf("%#x", 1);

Error in sprintf("%#x", 1) :
  use format %f, %e, %g or %a for numeric objects

Not sure if this was an intended move or not.

DETAILS:
Typically, the '#' flag modifies the output of (s)printf() as follows:

"# Used with o, x or X specifiers the value is preceeded with 0, 0x or 0X respectively for values different than zero. Used with e, E and f, it forces the written output to contain a decimal point even if no digits would follow. By default, if no digits follow, no decimal point is written. Used with g or G the result is the same as with e or E but trailing zeros are not removed."

Source: http://www.cplusplus.com/reference/clibrary/cstdio/printf.html

I know there are many flavors of what format strings printf() supports and I don't have the Kernighan & Ritchie book in help(sprintf).

/Henrik



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 02 Feb 2009 - 19:43:20 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 02 Feb 2009 - 20:30:18 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.

list of date sections of archive