From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23188 invoked by alias); 14 Aug 2018 15:25:39 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 22867 invoked by uid 89); 14 Aug 2018 15:25:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,HTML_MESSAGE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*c:alternative X-HELO: mail.avenger.ws Received: from mail.avenger.ws (HELO mail.avenger.ws) (173.208.129.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 14 Aug 2018 15:25:36 +0000 Received: from [IPv6:2804:14c:5b70:9002:7ccd:aa44:a280:b193] (unknown [IPv6:2804:14c:5b70:9002:7ccd:aa44:a280:b193]) by mail.avenger.ws (Postfix) with ESMTPSA id 424584E066B for ; Tue, 14 Aug 2018 12:25:15 -0300 (-03) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=avenger.ws; s=ethereal; t=1534260315; bh=vNOUq1ltDiyX48AVFtkKWnNTxAWzpOyhsghpzg6qrqE=; h=Subject:To:References:From:Date:In-Reply-To; b=YlwzxmXREG8/ymK1vPGzDkoAcl/iPRJrIXqIbTbjXkex91DVc8zlmJjAzKbG8ikfO 7ncF1I1G7qwUrNqTv/jBDTPPpYrRvugcHXsLg9C5Ijib+oKYl0UXjtWITIvVXmHv9R L2qOLWAVkZmjTTR4DUzPjLG27lL2F5ki/fYKh510= Subject: Re: strtod ("nan") returns negative NaN To: cygwin@cygwin.com References: <20180814.134527.917341694729989717.trueroad@trueroad.jp> <20180814_dot_134527_dot_917341694729989717_dot_trueroad_at_trueroad_dot_jp> <20180814095618.GT3747@calimero.vinschen.de> <20180815.000539.1012490218433540835.trueroad@trueroad.jp> From: Heavenly Avenger Message-ID: <6074ccd0-84a3-5395-4902-33028de1d9a4@avenger.ws> Date: Tue, 14 Aug 2018 15:35:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180815.000539.1012490218433540835.trueroad@trueroad.jp> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg00181.txt.bz2 Here's the result for a gentoo with the same code provided by Masamichi Hosoda. Linux ethereal 4.14.32-std522-amd64 #2 SMP Sat Mar 31 20:05:28 UTC 2018 x86_64 Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz GenuineIntel GNU/Linux strtof ("nan", NULL) = nan strtof ("-nan", NULL) = nan strtod ("nan", NULL) = nan strtod ("-nan", NULL) = nan strtold ("nan", NULL) = nan strtold ("-nan", NULL) = nan This further supports the reasoning to always return just 'nan'. On 8/14/2018 12:05 PM, Masamichi Hosoda wrote: > Hi > > I've found that strtod ("nan") returns negative NaN on Cygwin 64 bit. > https://cygwin.com/ml/cygwin/2018-08/msg00168.html > > On Linux with glibc, both strtod ("nan") > and strtod ("-nan") return positive NaN. > > So I've created the patch that behaves like glibc. > Both strtod ("nan") and strtod ("-nan") return positive NaN. > > Sample code: > ``` > #include > #include > > int main (void) > { > printf ("strtof (\"nan\", NULL) = %f\n", strtof ("nan", NULL)); > printf ("strtof (\"-nan\", NULL) = %f\n", strtof ("-nan", NULL)); > printf ("strtod (\"nan\", NULL) = %f\n", strtod ("nan", NULL)); > printf ("strtod (\"-nan\", NULL) = %f\n", strtod ("-nan", NULL)); > printf ("strtold (\"nan\", NULL) = %Lf\n", strtold ("nan", NULL)); > printf ("strtold (\"-nan\", NULL) = %Lf\n", strtold ("-nan", NULL)); > } > ``` > > The result of Cygwin (newlib) without my patch: > ``` > strtof ("nan", NULL) = nan > strtof ("-nan", NULL) = nan > strtod ("nan", NULL) = -nan > strtod ("-nan", NULL) = nan > strtold ("nan", NULL) = -nan > strtold ("-nan", NULL) = -nan > ``` > > The result of Linux (glibc, Ubuntu 16.04): > ``` > strtof ("nan", NULL) = nan > strtof ("-nan", NULL) = nan > strtod ("nan", NULL) = nan > strtod ("-nan", NULL) = nan > strtold ("nan", NULL) = nan > strtold ("-nan", NULL) = nan > ``` > > The result of FreeBSD 10.1 (BSD libc): > ``` > strtof ("nan", NULL) = nan > strtof ("-nan", NULL) = nan > strtod ("nan", NULL) = nan > strtod ("-nan", NULL) = nan > strtold ("nan", NULL) = nan > strtold ("-nan", NULL) = nan > ``` > > The result of Cygwin (newlib) with my patch: > ``` > strtof ("nan", NULL) = nan > strtof ("-nan", NULL) = nan > strtod ("nan", NULL) = nan > strtod ("-nan", NULL) = nan > strtold ("nan", NULL) = nan > strtold ("-nan", NULL) = nan > ``` > > Thanks. > > > -- > Problem reports: http://cygwin.com/problems.html > FAQ: http://cygwin.com/faq/ > Documentation: http://cygwin.com/docs.html > Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple