Skip to content

sprintf() question

2 messages · Ei-ji Nakama, Brian Ripley

#
Hi

The result of Windows is clearly strange.

================ my Linux machine =?good =======================
R version 2.9.0 (2009-04-17)
x86_64-pc-linux-gnu

locale:
LC_CTYPE=ja_JP.EUC-JP;LC_NUMERIC=C;LC_TIME=ja_JP.EUC-JP;LC_COLLATE=ja_JP.EUC-JP;
LC_MONETARY=C;LC_MESSAGES=ja_JP.EUC-JP;LC_PAPER=ja_JP.EUC-JP;LC_NAME=C;LC_ADDRES
S=C;LC_TELEPHONE=C;LC_MEASUREMENT=ja_JP.EUC-JP;LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
[1] "0x1p+0"   "0x1p+1"   "0x1.8p+1" "0x1p+2"   "0x1.4p+2" "0x1.8p+2" "0x1.cp+2"
[8] "0x1p+3"

================ my Windows machine = OMG ======================
R version 2.9.0 (2009-04-17)
i386-pc-mingw32

locale:
LC_COLLATE=Japanese_Japan.932;LC_CTYPE=Japanese_Japan.932;LC_MONETARY=Japanese_Japan.932;LC_NUMERIC=C;LC_TIME=Japanese_Japan.932

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
[1] "0x1p+0"            "0x1"               "0x1.8"
"0x1p+4294967294"
[5] "0x1.4p+4294967294" "0x1.8p+4294967294" "0x1.cp+4294967294"
"0x1p+4294967293"

The result improved when I changed handling of uExponent as follows

http://prs.ism.ac.jp/~nakama/working/sprintf_format_a.patch



2009/5/18 Daniel Nordlund <djnordlund at verizon.net>:

  
    
8 days later
#
Thank you, incorporated now.

As the help page says, %a is a C99 feature that is not available on 
all platforms.  The *printf in msvcrt.dll is a long way from 
C99-compatible (it dates from ca 10 years ago, but later VC runtimes 
are also incompatible).  Recently MinGW has attempted to supplement 
it, not very comprehensively.

Quite a while ago we switched R for Windows to use the trio emulation 
of *printf, which is intended to be compatible with C99.  This was a 
bug in a bugfix to trio (there have been quite a few bugfixes).
On Mon, 18 May 2009, Ei-ji Nakama wrote: