Re: [Rd] scan() doesn't like '1.#IND'

From: Dan Tenenbaum <>
Date: Wed, 08 Feb 2012 20:36:15 -0800

2012/2/8 Duncan Murdoch <>:
> On 12-02-08 8:59 PM, Hervé Pagès wrote:
>> Hi,
>> Since C++ code compiled with g++ 4.6.3 on Windows (the version included
>> in latest Rtools) now can produce things like '1.#IND' when writing
>> doubles to a file (using the<<  operator), I wonder whether scan()
>> shouldn't support those things. Right now (with recent R devel and
>> latest Rtools) we get errors like:
>>    Error in scan(file, what, nmax, sep, dec, quote, skip, nlines,
>> na.strings,  :
>>      scan() expected 'a real', got '-1.#IND'
>> that we didn't get with previous versions of R devel and Rtools.
>> See
>> for the details. (Note that the file containing the numeric values
>> is generated during the creation of the vignette.)
>> We don't see this error on Linux or Mac because on those platforms
>> the C++ code will produce 'nan' or 'inf', which are supported by
>> scan().
> Is that a bug in the C++ run-time, or is there a legitimate reason to
> produce 1.#IND?

I don't think it's a bug; it's just a different way of saying what earlier versions of g++ said when they generate "inf", namely that the number is too large to fit in a double. (The MSVC++ compiler has always used 1.#IND instead of inf, BTW, and now g++ has decided to do the same).

It does probably represent a floating-point exception in C++ code, but not a bug in the C++ runtime, so IMO it should be handled by scan() in the same way as 'inf', since the identical code may produce different error codes on different platforms.

Note also that there are other variations of the code, such as 11.#INF. See and for more information.


> If it's a C++ bug it makes more sense to fix it there than in R.
> Duncan Murdoch
> ______________________________________________
> mailing list
> mailing list Received on Thu 09 Feb 2012 - 04:40:03 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

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 Thu 09 Feb 2012 - 13:50:14 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive