X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=xr9onqkriQPo8QPc 2gLEb/7qsYMabrXricwdML034DG2uKugutC8YYITzs0KUIl00aFeXCplMkZZ6WEb EShw6+W0AigRWlB5lYpc/JutLZQL71YdKpJM/F6fGlO6Q/4NLqVvHV7ggiAVPA/6 ZoAz52ovO4qt3CDeSJp9518kBvU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=PIRwtuu0/hfAj+k7Ksh1ck L8njg=; b=C9zudaXnzikwtb4nNuJJRYrRKvm/fwEe0PAoWO3PTVWZ2lT2A/IvcQ yKZxe40Ac+3SBLmcsue8loOkna8W/vek/ReXr6Wf2TS7veJoD/6m312uznxHNZ3i u4XAcHPOho+GyGy/bM3fTjqQMkDgqwWR5sXgmaSS99pw4UkjquvXc= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 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 AT cygwin DOT com References: <20180814 DOT 134527 DOT 917341694729989717 DOT trueroad AT trueroad DOT jp> <20180814_dot_134527_dot_917341694729989717_dot_trueroad_at_trueroad_dot_jp> <20180814095618 DOT GT3747 AT calimero DOT vinschen DOT de> <20180815 DOT 000539 DOT 1012490218433540835 DOT trueroad AT trueroad DOT jp> From: Heavenly Avenger Message-ID: <6074ccd0-84a3-5395-4902-33028de1d9a4@avenger.ws> Date: Tue, 14 Aug 2018 12:24:27 -0300 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 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