From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 109842 invoked by alias); 14 Aug 2018 19:24:20 -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 109786 invoked by uid 89); 14 Aug 2018 19:24:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-spam-relays-external:ESMTPA X-HELO: vsmx012.vodafonemail.xion.oxcs.net Received: from vsmx012.vodafonemail.xion.oxcs.net (HELO vsmx012.vodafonemail.xion.oxcs.net) (153.92.174.90) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 14 Aug 2018 19:24:13 +0000 Received: from vsmx004.vodafonemail.xion.oxcs.net (unknown [192.168.75.198]) by mta-8-out.mta.xion.oxcs.net (Postfix) with ESMTP id BB5618CDD7F for ; Tue, 14 Aug 2018 19:24:10 +0000 (UTC) Received: from Gertrud (unknown [87.185.210.65]) by mta-8-out.mta.xion.oxcs.net (Postfix) with ESMTPA id 8FBEACDFA4 for ; Tue, 14 Aug 2018 19:24:08 +0000 (UTC) From: Achim Gratz To: cygwin@cygwin.com Subject: Re: strtod ("nan") returns negative NaN References: <20180814.100952.1684125661222835312.trueroad@trueroad.jp> <20180814.113135.1571893395887584078.trueroad@trueroad.jp> <20180814.134527.917341694729989717.trueroad@trueroad.jp> <20180814095618.GT3747@calimero.vinschen.de> <20180814103900.GU3747@calimero.vinschen.de> Date: Tue, 14 Aug 2018 19:44:00 -0000 In-Reply-To: <20180814103900.GU3747@calimero.vinschen.de> (Corinna Vinschen's message of "Tue, 14 Aug 2018 12:39:00 +0200") Message-ID: <87lg98eoq2.fsf@Rainer.invalid> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SW-Source: 2018-08/txt/msg00187.txt.bz2 Corinna Vinschen writes: > With your patch, strtold looks more correct, but it still prints the > sign of NaN: > > strtod ("nan", NULL) = nan > strtod ("-nan", NULL) = nan > strtold ("nan", NULL) = nan > strtold ("-nan", NULL) = -nan > nan ("") = nan > > Question: What's wrong with that? Wouldn't it be more correct if > strtod returns -NaN for "-nan" as well? That's iffy, the treatment of sign bits for NaN is quite different from the usual arithmetic rules. A NaN is literally "not a number", i.e. the computation has left the domain of representable FP numbers, so it really doesn't have a sign. That doesn't stop folks from using the sign bit on its representation, but that's a different story. The sign properly belong to what is called the "payload", which is usally ignored. So converting "-nan" (or NaN multiplied by -1) really ought to be just plain NaN. Regards, Achim. -- +<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+ Factory and User Sound Singles for Waldorf rackAttack: http://Synth.Stromeko.net/Downloads.html#WaldorfSounds -- 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