X-Spam-Check-By: sourceware.org
Message-ID: <af54caaf0606201000o4df93c69scbc55bf24f12915d@mail.gmail.com>
Date: Tue, 20 Jun 2006 13:00:45 -0400
From: "Paul Biggar" <paul.biggar@gmail.com>
To: cygwin@cygwin.com
Subject: strtod (and atof) on hex numbers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com

Hi,

atof (and hence strtod) on hexadecimal numbers results in 0.0 (errno
of 0). This may be related to an old issue where NaN isnt correctly
parsed. I believe it isnt correct behaviour:

http://www.opengroup.org/onlinepubs/000095399/functions/atof.html



I've tested it for integers in the range 0x8000000 to 0xFFFFFFFF. It
works properly on

ubuntu dapper, gcc 4.1 on i386;
debian stable, gcc 3.3 on amd64
sunos ?, gcc 3.4 on sparc

I'm using standard cygwin distribution, which uses gcc 3.4.4 (cygming special)

Sample code:

#include "limits.h"
#include <iostream.h>
#include "errno.h"

int main()

{
        cout << ULONG_MAX << endl;
        cout << 0xFFFFFFFF << endl;

        errno = 0;
        cout << atof("0xFFFFFFFF") << endl;
        cout << errno << endl;

        errno = 0;
        cout << strtod("0xFFFFFFFF", NULL) << endl;
        cout << errno << endl;

}


Is this being fixed? I could find a mention of it before. Does anyone
know a simple workaround?

Thanks
Paul



-- 
Paul Biggar
paul.biggar@gmail.com

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

