X-Sybari-Space: 00000000 00000000 00000000 00000000 From: Martin Stromberg Message-Id: <200304071443.QAA22691@lws256.lu.erisoft.se> Subject: Re: Support for nan(0x[0-9a-f]*) in strto*, *printf To: djgpp-workers AT delorie DOT com Date: Mon, 7 Apr 2003 16:43:08 +0200 (MET DST) In-Reply-To: <200304031505.RAA19060@lws256.lu.erisoft.se> from "Martin Stromberg" at Apr 03, 2003 05:05:08 PM X-Mailer: ELM [version 2.5 PL3] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk Hi. I said: > I propose all strto*() do use an unsigned long long to store the > mantissa (X) given in "nan(X)". If X > the maximum for float or > double, set the mantissa to all-ones (we clamp the value to the > maximum possible). > > This will make ``strtof(sprintf(s, "%d", NAN), NULL)'' return a > NaN. Am I confused or what? ``strtof(sprintf(s, "%d", NAN), NULL)'' would return a NaN even in my earlier posted implementation. The only difference is that the bits might be set differently. Do you have any preferences (clamping or masking)? > If *printf() will handle NaN in a double separately from long doubles > this should make ``double value1 = > extreme_cpu_use_generating_unusual_nans(); > double value2 = strtod(sprintf(s, "%d", value1), NULL)'' make the bit > pattern of value1 == the bit pattern of value2. This is sane though (IMO). Right, MartinS