WebSphere Message Service Clients: Web Services Client for C++, Version 1.1 Operating Systems: Linux, Windows

Floating point numbers

This section provides reference information about using floating point numbers with Web Services Client for C++.

The XML specification refers to the IEEE specification for floating point numbers. The specification lists that float and double have the following precision:

For float, with a mantissa able to represent any number in the range 1 > x > 1/223, this gives a minimum accuracy of 6 digits. Similarly, for double, with a mantissa able to represent any number in the range 1 > x > 1/252, this gives a minimum accuracy of 10 digits.

When displaying floating point numbers, you must ensure that any potential inaccuracies due to rounding errors, and so on are not visible. Therefore, to ensure the correct level of precision, for float types, instead of using:

printf( "%f", myFloat); 

you must use the following formatting command:

printf( "%.6g", myFloat);

Similarly, to ensure the correct level of precision for double types, instead of using:

printf( "%f", myDouble);

you must use the following formatting command:

printf( "%.10g", myDouble);
Related concepts
WSDL2Ws tool
Client API
Related tasks
Coding and building client applications

Reference topic

Terms of Use | Rate this page

Last updated: 25 Jan 2006

© Copyright IBM Corporation 2005, 2006. All Rights Reserved.