[ 
http://issues.apache.org/jira/browse/AXISCPP-838?page=comments#action_12358360 
] 

Fred Preston commented on AXISCPP-838:
--------------------------------------

I have tried to compromise on this.  The XML spec for floats refers back to the 
IEEE specifications.  This is defined as follows:-
float               = sign bit, 8  bit exponent, 23 bit mantissa
double          = sign bit, 11 bit exponent, 52 bit mantissa
long double = sign bit, 15 bit exponent, 64 bit mantissa

Float should be able to support 6 significant digits without rounding errors.  
Thus 555.555 will be supported, but 555.5549 will not (although it may be able 
to accuately represent this number).  By replacing

    AxisSprintf (serializedValue, 80, "%f", *value);

with

    AxisSprintf (serializedValue, 80, "%.6g", *value);

in float.cpp, xsd__float should cope with 6 significant digits, but will round 
up if more digits are supplied.  For example,

555.555 will be serialised as 555.555 but 555.5549 will also be serialised as 
555.555.

This needs to be raised as a note, but this is a restriction of the XML/IEEE 
specification.

> The serialisation of 555.555 as a float produces a value of 555.554993 on the 
> wire.
> -----------------------------------------------------------------------------------
>
>          Key: AXISCPP-838
>          URL: http://issues.apache.org/jira/browse/AXISCPP-838
>      Project: Axis-C++
>         Type: Bug
>   Components: Serialization
>  Environment: n/a
>     Reporter: Fred Preston
>     Assignee: Fred Preston

>
> Using the UnitTest_XSD_float test.  If you change the code as follows:-
> Was
> [40]// Test non-nillable element
> [41]      xsd__float result = ws->asNonNillableElement((xsd__float)35.353588);
> Now
> [40]// Test non-nillable element
> [41]      xsd__float result = ws->asNonNillableElement((xsd__float)555.555);
> Then on the wire you get:-
> <nonNillableElement>555.554993</nonNillableElement>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to