float stuff again

Nathan Myers ncm-nospam@cantrip.org
Tue Jan 22 22:11:00 GMT 2002


On Wed, Jan 23, 2002 at 03:38:00AM +0100, Gabriel Dos Reis wrote:
> | Nathan pointed out some errors in the num_get code as it currently stands 
> | to me in a private email. Basically, all numbers should be extracted, 
> | regardless of numeric_limits length limits. I suspect this will impact 
> | this discussion, but am unwilling to comment more before I get a chance 
> | to carefully review the issue. 
> 
> OK.  Please Cc: me in case you have further discussion on the issue.

Clarifying...  As I understand the standard, extractors are supposed
to extract all well-formed numeric sequences, ignoring any 
representational limits.  While reading, they may discard extra digits 
once they determine they can't contribute to the extraction, either 
because it already overflowed, or described more precision than exists.

For example, the sequences below should be read all the way to the ":"
(assumng digit group separator is "," and decimal separator is "."):

  1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,11111111:
  00000000000000000000000000000000000000000000000000000099999999:
  1.500000000000000000000000000000000000000000000000000000000001:
  1.5e0000000000000000000000000000000000000000000000000000000001:
  1.5e1000000000000000000000000000000000000000000000000000000000:

The first and last (probably) should result in failbit set; the rest 
are fine.  This means that while extracting, there are states: reading 
leading zeroes (which don't need to be stored), reading possibly good 
digits (which may be examined later) and reading extra digits (which 
either add to an already-known overflow condition, or cannot change
the result of the conversion).

Storing a few more digits than you can represent is harmless, as
long as the conversion itself reports the overflow.

Nathan Myers
ncm@cantrip.org



More information about the Libstdc++ mailing list