Real Number Types

XSD defines the following types that are mapped to the C double type:

A double is always used because it provides the maximum precision to hold numbers for all of the types above.

The general mapping is as follows:

XSD type:

   <xsd:simpleType name="TypeName">
      <restriction base="xsd:float"/>
   </xsd:simpleType>

Generated C code:

   typedef OSREAL TypeName;

Generated C++ code:

   class TypeName : public OSRTBaseType {
      OSREAL value;
      ...
   } ;

The character representation of these numeric types in generated messages can be altered by using a configuration file. This allows behavior such as preservation of leading zeros to be specified.

The <typemap>declarations can be used to map a real number type or a list of real number types separated by space to a string type. This can be done at global or schema level. This mapping configuration can be used to preserve the format of floating point numbers after decoding and reencoding.

For example, to map xsd:double types to string:

   <typemap>
      <xsdtype>double</xsdtype>
      <ctype>string</ctype>
   </typemap>

For more information, see the XML Numeric Values Format Specificationsection.