简体   繁体   中英

Floating point numbers in XML

what is the best way to handle floating point numbers in XML? If I have, for instance:

double a = 123.456;

and I would like to keep it as

<A> 123.456 </A>

simply using ...

myDoc.createTextNode(a.ToString());

is fine? Or should it be done with some Globalization stuff to make it region-independent?

Have a look at the XmlConvert class, specifically the XmlConvert.ToString Method (Double) .

[The XmlConvert Class] provides methods for converting between common language runtime types and XML Schema definition language (XSD) types. When converting data types the values returned are locale independent.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM