Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 513426

Summary: string to double conversion results in questionable precision
Product: Red Hat Enterprise MRG Reporter: Rafael H. Schloming <rafaels>
Component: qpid-javaAssignee: Rajith Attapattu <rattapat+nobody>
Status: CLOSED ERRATA QA Contact: Jiri Kolar <jkolar>
Severity: medium Docs Contact:
Priority: low    
Version: 1.2CC: cctrieloff, gsim, jkolar, tross
Target Milestone: 1.3   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Previously, a string to double conversion returned imprecise results. With this update, string values are correctly converted directly to double values instead of converting them to a float value and then to a double value.
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-10-14 15:58:10 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Rafael H. Schloming 2009-07-23 15:29:40 UTC
The following test:
 
public void testString2Double_1() {
    try {
      Message message = senderSession.createMessage();
      message.setStringProperty("pi", "3.14159");
      assertEquals(3.14159, message.getDoubleProperty("pi"),0);
    } catch (JMSException e) {
      fail(e);
    }
  }
 
Fails with:
 
        junit.framework.AssertionFailedError: expected:<3.14159> but was:<3.141590118408203>

This appears to be because the client ends up doing the equivalent of Double.valueOf(Float.valueOf(value)) when doing string to double conversion rather than the more direct Double.valueOf(value).

Comment 4 Jiri Kolar 2010-09-30 14:17:50 UTC
fixed in qpid-java-client-0.7.946106-10.el5
validated on RHEL5.5/RHEL 4.8  i386 / x86_64  

packages:
# rpm -qa | grep -E '(qpid|openais|rhm)' | sort -u
openais-0.80.6-16.el5_5.7
openais-devel-0.80.6-16.el5_5.7
python-qpid-0.7.946106-14.el5
qpid-cpp-client-0.7.946106-17.el5
qpid-cpp-client-devel-0.7.946106-17.el5
qpid-cpp-client-devel-docs-0.7.946106-17.el5
qpid-cpp-client-ssl-0.7.946106-17.el5
qpid-cpp-mrg-debuginfo-0.7.946106-14.el5
qpid-cpp-server-0.7.946106-17.el5
qpid-cpp-server-cluster-0.7.946106-17.el5
qpid-cpp-server-devel-0.7.946106-17.el5
qpid-cpp-server-ssl-0.7.946106-17.el5
qpid-cpp-server-store-0.7.946106-17.el5
qpid-cpp-server-xml-0.7.946106-17.el5
qpid-java-client-0.7.946106-10.el5
qpid-java-common-0.7.946106-10.el5
qpid-tools-0.7.946106-11.el5
rhm-docs-0.7.946106-5.el5
rh-tests-distribution-MRG-Messaging-qpid_common-1.6-53

->VERIFIED

Comment 5 Rajith Attapattu 2010-10-07 18:28:52 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause: String to double conversion results in questionable precision.

Consequence: If we set a property name "pi" as follows message.setStringProperty("pi", "3.14159");
And when it's retrieved as double using message.getDoubleProperty("pi"),0) it returns "3.141590118408203"

Fix: The code now correctly converts the string value directly to double instead of converting it to a float and then to a double.


Result: The get method now returns the value with the correct precision.

Comment 6 Martin Prpič 2010-10-10 11:43:49 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,9 +1 @@
-Cause: String to double conversion results in questionable precision.
+Previously, a string to double conversion returned imprecise results. With this update, string values are correctly converted directly to double values instead of converting them to a float value and then to a double value.-
-Consequence: If we set a property name "pi" as follows message.setStringProperty("pi", "3.14159");
-And when it's retrieved as double using message.getDoubleProperty("pi"),0) it returns "3.141590118408203"
-
-Fix: The code now correctly converts the string value directly to double instead of converting it to a float and then to a double.
-
-
-Result: The get method now returns the value with the correct precision.

Comment 8 errata-xmlrpc 2010-10-14 15:58:10 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2010-0773.html