You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Schmid, David" <sc...@cajvc.com> on 2001/11/02 22:42:13 UTC

Validation of doubles and floats?

 Hello

 I am having some trouble with my schema and instance docs with values that
are 0. The validator for doubles and floats keeps telling me that my value
of 0.0 is not between the min negative number (a very tiny negative number)
and the min positive number (a very tiny positive number), which is
mathematically true, but I don't think this makes it an invalid float or
double.

 However, if my value is exactly the string '0' or '-0', as opposed to '0.0'
or '0.00' etc, the validator is OK with it.

 Is there something in the spec that says that zero values must be
represented exactly by the string '0', or can the validator be made smarter
to know that '0.0' and various other strings that really mean zero are in
fact in the allowable range for floats and doubles?

Thanks




---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org


Re: Validation of doubles and floats?

Posted by PeiYong Zhang <pe...@ca.ibm.com>.
David,

   The following is an excerpt from the spec, it does mention that the lexcial
representation for positive and negative zero is "0" and "-0" respectively,
though it does NOT explicitly forbid other lexcial notions for these two values.

   If we are going to allow "0.0", "0.00", then positive zero and negative zero
are going to have more lexcial representation than what the specs explicitly
allows. (even we are to do that, we may face issue such as how many leading
zeros we are going to accomodate, or shall we truncate those unrepresentable to
zero as well, etc.)

   To this extend, the parser is comformant to the specs as it does what is
told, all told, nothing but told.

Rgds,
PeiYong Zhang

Excerpt from the specs:
------------------------
 3.2.4.1 Lexical representation
...

The special values positive and negative zero, positive and negative infinity
and not-a-number have lexical representations 0, -0, INF, -INF and NaN,
respectively.



"Schmid, David" wrote:

>  Hello
>
>  I am having some trouble with my schema and instance docs with values that
> are 0. The validator for doubles and floats keeps telling me that my value
> of 0.0 is not between the min negative number (a very tiny negative number)
> and the min positive number (a very tiny positive number), which is
> mathematically true, but I don't think this makes it an invalid float or
> double.
>
>  However, if my value is exactly the string '0' or '-0', as opposed to '0.0'
> or '0.00' etc, the validator is OK with it.
>
>  Is there something in the spec that says that zero values must be
> represented exactly by the string '0', or can the validator be made smarter
> to know that '0.0' and various other strings that really mean zero are in
> fact in the allowable range for floats and doubles?
>
> Thanks
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-c-dev-help@xml.apache.org