I have a typed dataset with a field (represented as an xml attribute) of
type float (xs:float).
The value is at some point float.NaN (Not a number).

I do: myDataSet.WriteXml(theNameOfTheXmlFile, XmlWriteMode.IgnoreSchema);
In the xml file, this is now represented as: MyNameSpacePrefix:MyFloat="NaN"

So far so good, but when I try to read this xml file into the dataset later,
by: myDataSet.ReadXml(theNameOfTheXmlFile, XmlReadMode.IgnoreSchema);
a System.FormatException (additional text: Input string was not in a correct
format) is thrown due to this "NaN".

Anyone knows if it is possible (and how) to read back a "NaN" from an xml
file and make it be represented as float.NaN ?

RE: NaN (Not a number) and DataSet by BradRoberts

BradRoberts
Thu Aug 19 12:51:03 CDT 2004

One solution would be to disallow nulls in the database table and default it
to 0.0

"Magne Ryholt" wrote:

> I have a typed dataset with a field (represented as an xml attribute) of
> type float (xs:float).
> The value is at some point float.NaN (Not a number).
>
> I do: myDataSet.WriteXml(theNameOfTheXmlFile, XmlWriteMode.IgnoreSchema);
> In the xml file, this is now represented as: MyNameSpacePrefix:MyFloat="NaN"
>
> So far so good, but when I try to read this xml file into the dataset later,
> by: myDataSet.ReadXml(theNameOfTheXmlFile, XmlReadMode.IgnoreSchema);
> a System.FormatException (additional text: Input string was not in a correct
> format) is thrown due to this "NaN".
>
> Anyone knows if it is possible (and how) to read back a "NaN" from an xml
> file and make it be represented as float.NaN ?
>
>
>
>

Re: NaN (Not a number) and DataSet by Magne

Magne
Thu Aug 19 13:46:30 CDT 2004

I don't read from a database, but from an excel sheet which I have no
control over.
This excel sheet has a mix of empty cells and cells with float numbers and I
need a way to represent an empty cell.
Further I need to store the values in xml (by using the beforementioned
methofs around DataSet.
I cannot use 0.0 as representation of an empty cell because this would be a
perfectly legal value and semantically different from an empty cell.

"Brad Roberts" <BradRoberts@discussions.microsoft.com> wrote in message
news:13CBC204-329F-415F-AC3F-FF99B1DDF7B6@microsoft.com...
> One solution would be to disallow nulls in the database table and default
it
> to 0.0
>
> "Magne Ryholt" wrote:
>
> > I have a typed dataset with a field (represented as an xml attribute) of
> > type float (xs:float).
> > The value is at some point float.NaN (Not a number).
> >
> > I do: myDataSet.WriteXml(theNameOfTheXmlFile,
XmlWriteMode.IgnoreSchema);
> > In the xml file, this is now represented as:
MyNameSpacePrefix:MyFloat="NaN"
> >
> > So far so good, but when I try to read this xml file into the dataset
later,
> > by: myDataSet.ReadXml(theNameOfTheXmlFile, XmlReadMode.IgnoreSchema);
> > a System.FormatException (additional text: Input string was not in a
correct
> > format) is thrown due to this "NaN".
> >
> > Anyone knows if it is possible (and how) to read back a "NaN" from an
xml
> > file and make it be represented as float.NaN ?
> >
> >
> >
> >
>