X-Authentication-Warning: acp3bf.physik.rwth-aachen.de: broeker owned process doing -bs Date: Wed, 15 Mar 2000 15:05:52 +0100 (MET) From: Hans-Bernhard Broeker X-Sender: broeker AT acp3bf To: djgpp-workers AT delorie DOT com Subject: Re: Unnormals??? In-Reply-To: <200003151300.IAA05344@delorie.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp-workers AT delorie DOT com Errors-To: dj-admin AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Wed, 15 Mar 2000, Dieter Buerssner wrote: > On 15 Mar 00, Eli Zaretskii wrote: > > We print Unnormal for something that is not a valid FP number, like if > > you fill a buffer with arbitrary text and then pass it to a function > > which expects a double. > > Let me add, that when I am not totally mistaken, there can be no > unnormals for type double (or float), because these types have and > implicit set bit msb for the mantissa. This is not true for type long > double. My foggy memory seconds this description. I'll have to look into my 8087-80387 coding book (written by one of the makers of 8087) at home to verify the details. [... printed rep's of 'unnormals'] > > > The standard doesn't mention them. Is this ok? > > > > The standard also doesn't say it cannot be done. > > I read 17.19.6.1 in the C99 draft. To me it seems it does not allow > this. Agreed, on this one, too. AFAIK, if the standard lists a set of options, that's exactly the set of options you have. I.e., by not mentioning other options the C99 standard says that setting aside format modifiers, we are only allowed to print out numbers as usual, "inf", "infinity", "nan", or "nan{somestring}", where "{somestring}" is an implementation-defined string. The latter allows us as the implementation definers to choose whatever we want for this string. Can be descriptive useful information, or just a printf("%x") of the mantissa bits, or whatever else we see fit. Or nothing at all. But: we have to ensure that 'scanf()' also can parse the whole "nanblabla" and translate it back to a NaN number. > Perhaps, it would be preferable, to print "nan(unnormal)" for the > unnormal case, to be std conform. *If* an unnormal is a NaN, yes. The question still hovering in my head would then be what the difference is between a subnormal (supposed to be detectable by C99 functions) and an unnormal (mentioned nowhere in the whole draft). I remember having discussed this before, on this list, but not the details... Subnormals as defined by C99 are fp numbers with smallest possible exponent, and a mantissa smaller than 0.5 (i.e. no leading one-bit). These can only happen for 'long double', indeed, as the other formats use a hidden leading one-bit for the mantissa. Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.