You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Jeff Whiting (JIRA)" <ji...@apache.org> on 2009/12/09 01:31:18 UTC

[jira] Created: (THRIFT-644) Doubles are not IEEE 754 when writing in the BinaryFormat

Doubles are not IEEE 754 when writing in the BinaryFormat
---------------------------------------------------------

                 Key: THRIFT-644
                 URL: https://issues.apache.org/jira/browse/THRIFT-644
             Project: Thrift
          Issue Type: Bug
          Components: Compiler (PHP)
    Affects Versions: 0.1, 0.2, 0.3
         Environment: PHP 5.3 - Ubuntu 9.10
Most likely all OSes 
            Reporter: Jeff Whiting


Steps to Repro:
1.  Without the PHP thrift extension serialize a struct with a double (note I haven't tested this with the php extension)
2. Attempt to read the struct using Java

Results:
Java is unable to read the double correctly

Expected Results:
Looking at the PHP code in TBinaryProtocol.php the function writeDouble does the following:
$data = pack('d', $value); 

According to the PHP documentation (http://php.net/manual/en/function.pack.php)
'd' is: double (machine dependent size and representation).
The double should be IEEE 754 compliant.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-644) Doubles are not IEEE 754 when writing in the BinaryFormat

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12787946#action_12787946 ] 

David Reiss commented on THRIFT-644:
------------------------------------

Can you give some more information about what Java produces?  Can you also tell us the specific double value that causes it and what $data is?

> Doubles are not IEEE 754 when writing in the BinaryFormat
> ---------------------------------------------------------
>
>                 Key: THRIFT-644
>                 URL: https://issues.apache.org/jira/browse/THRIFT-644
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (PHP)
>    Affects Versions: 0.1, 0.2, 0.3
>         Environment: PHP 5.3 - Ubuntu 9.10
> Most likely all OSes 
>            Reporter: Jeff Whiting
>
> Steps to Repro:
> 1.  Without the PHP thrift extension serialize a struct with a double (note I haven't tested this with the php extension)
> 2. Attempt to read the struct using Java
> Results:
> Java is unable to read the double correctly
> Expected Results:
> Looking at the PHP code in TBinaryProtocol.php the function writeDouble does the following:
> $data = pack('d', $value); 
> According to the PHP documentation (http://php.net/manual/en/function.pack.php)
> 'd' is: double (machine dependent size and representation).
> The double should be IEEE 754 compliant.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-644) Doubles are not IEEE 754 when writing in the BinaryFormat

Posted by "Jeff Whiting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788806#action_12788806 ] 

Jeff Whiting commented on THRIFT-644:
-------------------------------------

I'll try to run the tests today and get back to you.

The funny thing was that Java wasn't giving an error--it would abruptly stop reading the binary format.  We have a container struct that has a map of Timing.thrift structs as well maps of other structs without doubles.  Once the java reader got to a struct that has a double in it would stop reading any structs after it.  As soon as we changed the double to an i32 or a string the java program would read all of the structs.  It was because of this that I assumed there was a problem with the double encoding in php.



> Doubles are not IEEE 754 when writing in the BinaryFormat
> ---------------------------------------------------------
>
>                 Key: THRIFT-644
>                 URL: https://issues.apache.org/jira/browse/THRIFT-644
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (PHP)
>    Affects Versions: 0.1, 0.2, 0.3
>         Environment: PHP 5.3 - Ubuntu 9.10 - 32 bit
> Most likely all OSes 
>            Reporter: Jeff Whiting
>         Attachments: Timing.thrift
>
>
> Steps to Repro:
> 1.  Without the PHP thrift extension serialize a struct with a double (note I haven't tested this with the php extension)
> 2. Attempt to read the struct using Java
> Results:
> Java is unable to read the double correctly
> Expected Results:
> Looking at the PHP code in TBinaryProtocol.php the function writeDouble does the following:
> $data = pack('d', $value); 
> According to the PHP documentation (http://php.net/manual/en/function.pack.php)
> 'd' is: double (machine dependent size and representation).
> The double should be IEEE 754 compliant.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (THRIFT-644) Doubles are not IEEE 754 when writing in the BinaryFormat

Posted by "Jeff Whiting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788167#action_12788167 ] 

Jeff Whiting edited comment on THRIFT-644 at 12/9/09 5:19 PM:
--------------------------------------------------------------

I've attached the thrift file we are using.  The values we have set for each property are as follows:

firstClick = 0.14000000000000001332267629550187848508358001708984375
lastClick = 9.25
pageSubmit = 0.520000000000000017763568394002504646778106689453125
clickCount = 43

Just for some background information, we are attempting to move away from the php serialized arrays and to thrift. I've pulled these values directly from the php serialized array we are currently using.

Honestly I don't know enough about the thrift binary format to be able to look at two different binary encodings and tell you what is going on.  

However, I have looked at the java code (TBinaryProtocol.java) and it encodes doubles using Double.doubleToLongBits and according to http://java.sun.com/javase/6/docs/api/java/lang/Double.html#doubleToLongBits%28double%29 it is using a IEEE 754 encoding. Unfortunately php pack function produces a double that is "machine dependent size and representation."  So I'm assuming the problem is that the double is being represented differently between java and php.

As far as $data variable, that is just from the function writeDouble found in TBinaryProtocol.php.  Here is the entire function for more context:

<pre>
public function writeDouble($value) {
 	$data = pack('d', $value);
 	$this->trans_->write(strrev($data), 8);
 	return 8;
} 
</pre>

      was (Author: whitingj):
    I've attached the thrift file we are using.  The values we have set for each property are as follows:

firstClick = 0.14000000000000001332267629550187848508358001708984375
lastClick = 9.25
pageSubmit = 0.520000000000000017763568394002504646778106689453125
clickCount = 43

Just for some background information, we are attempting to move away from the php serialized arrays and to thrift. I've pulled these values directly from the php serialized array we are currently using.

Honestly I don't know enough about the thrift binary format to be able to look at two different binary encodings and tell you what is going on.  

However, I have looked at the java code (TBinaryProtocol.java) and it encodes doubles using Double.doubleToLongBits and according to http://java.sun.com/javase/6/docs/api/java/lang/Double.html#doubleToLongBits%28double%29 it is using a IEEE 754 encoding. Unfortunately php pack function produces a double that is "machine dependent size and representation."  So I'm assuming the problem is that the double is being represented differently between java and php.

As far as $data variable, that is just from the function writeDouble found in TBinaryProtocol.php.  Here is the entire function for more context:

public function writeDouble($value) {

 	$data = pack('d', $value);

 	$this->trans_->write(strrev($data), 8);

 	return 8;

} 
  
> Doubles are not IEEE 754 when writing in the BinaryFormat
> ---------------------------------------------------------
>
>                 Key: THRIFT-644
>                 URL: https://issues.apache.org/jira/browse/THRIFT-644
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (PHP)
>    Affects Versions: 0.1, 0.2, 0.3
>         Environment: PHP 5.3 - Ubuntu 9.10
> Most likely all OSes 
>            Reporter: Jeff Whiting
>         Attachments: Timing.thrift
>
>
> Steps to Repro:
> 1.  Without the PHP thrift extension serialize a struct with a double (note I haven't tested this with the php extension)
> 2. Attempt to read the struct using Java
> Results:
> Java is unable to read the double correctly
> Expected Results:
> Looking at the PHP code in TBinaryProtocol.php the function writeDouble does the following:
> $data = pack('d', $value); 
> According to the PHP documentation (http://php.net/manual/en/function.pack.php)
> 'd' is: double (machine dependent size and representation).
> The double should be IEEE 754 compliant.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-644) Doubles are not IEEE 754 when writing in the BinaryFormat

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788201#action_12788201 ] 

David Reiss commented on THRIFT-644:
------------------------------------

Please apply the patches from THRIFT-592 and THRIFT-645, then run "ant testserver" to start a Java server and "cd test/php && make && ./TestClient.php" to run the PHP client.  Let us know whether this reproduces the problem.

> Doubles are not IEEE 754 when writing in the BinaryFormat
> ---------------------------------------------------------
>
>                 Key: THRIFT-644
>                 URL: https://issues.apache.org/jira/browse/THRIFT-644
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (PHP)
>    Affects Versions: 0.1, 0.2, 0.3
>         Environment: PHP 5.3 - Ubuntu 9.10 - 32 bit
> Most likely all OSes 
>            Reporter: Jeff Whiting
>         Attachments: Timing.thrift
>
>
> Steps to Repro:
> 1.  Without the PHP thrift extension serialize a struct with a double (note I haven't tested this with the php extension)
> 2. Attempt to read the struct using Java
> Results:
> Java is unable to read the double correctly
> Expected Results:
> Looking at the PHP code in TBinaryProtocol.php the function writeDouble does the following:
> $data = pack('d', $value); 
> According to the PHP documentation (http://php.net/manual/en/function.pack.php)
> 'd' is: double (machine dependent size and representation).
> The double should be IEEE 754 compliant.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (THRIFT-644) Doubles are not IEEE 754 when writing in the BinaryFormat

Posted by "Jeff Whiting (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-644?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jeff Whiting updated THRIFT-644:
--------------------------------

    Comment: was deleted

(was: The thrift file we are using)

> Doubles are not IEEE 754 when writing in the BinaryFormat
> ---------------------------------------------------------
>
>                 Key: THRIFT-644
>                 URL: https://issues.apache.org/jira/browse/THRIFT-644
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (PHP)
>    Affects Versions: 0.1, 0.2, 0.3
>         Environment: PHP 5.3 - Ubuntu 9.10
> Most likely all OSes 
>            Reporter: Jeff Whiting
>         Attachments: Timing.thrift
>
>
> Steps to Repro:
> 1.  Without the PHP thrift extension serialize a struct with a double (note I haven't tested this with the php extension)
> 2. Attempt to read the struct using Java
> Results:
> Java is unable to read the double correctly
> Expected Results:
> Looking at the PHP code in TBinaryProtocol.php the function writeDouble does the following:
> $data = pack('d', $value); 
> According to the PHP documentation (http://php.net/manual/en/function.pack.php)
> 'd' is: double (machine dependent size and representation).
> The double should be IEEE 754 compliant.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (THRIFT-644) Doubles are not IEEE 754 when writing in the BinaryFormat

Posted by "Jeff Whiting (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-644?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jeff Whiting updated THRIFT-644:
--------------------------------

    Attachment: Timing.thrift

The thrift file we are using

> Doubles are not IEEE 754 when writing in the BinaryFormat
> ---------------------------------------------------------
>
>                 Key: THRIFT-644
>                 URL: https://issues.apache.org/jira/browse/THRIFT-644
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (PHP)
>    Affects Versions: 0.1, 0.2, 0.3
>         Environment: PHP 5.3 - Ubuntu 9.10
> Most likely all OSes 
>            Reporter: Jeff Whiting
>         Attachments: Timing.thrift
>
>
> Steps to Repro:
> 1.  Without the PHP thrift extension serialize a struct with a double (note I haven't tested this with the php extension)
> 2. Attempt to read the struct using Java
> Results:
> Java is unable to read the double correctly
> Expected Results:
> Looking at the PHP code in TBinaryProtocol.php the function writeDouble does the following:
> $data = pack('d', $value); 
> According to the PHP documentation (http://php.net/manual/en/function.pack.php)
> 'd' is: double (machine dependent size and representation).
> The double should be IEEE 754 compliant.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-644) Doubles are not IEEE 754 when writing in the BinaryFormat

Posted by "Jeff Whiting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788167#action_12788167 ] 

Jeff Whiting commented on THRIFT-644:
-------------------------------------

I've attached the thrift file we are using.  The values we have set for each property are as follows:

firstClick = 0.14000000000000001332267629550187848508358001708984375
lastClick = 9.25
pageSubmit = 0.520000000000000017763568394002504646778106689453125
clickCount = 43

Just for some background information, we are attempting to move away from the php serialized arrays and to thrift. I've pulled these values directly from the php serialized array we are currently using.

Honestly I don't know enough about the thrift binary format to be able to look at two different binary encodings and tell you what is going on.  

However, I have looked at the java code (TBinaryProtocol.java) and it encodes doubles using Double.doubleToLongBits and according to http://java.sun.com/javase/6/docs/api/java/lang/Double.html#doubleToLongBits%28double%29 it is using a IEEE 754 encoding. Unfortunately php pack function produces a double that is "machine dependent size and representation."  So I'm assuming the problem is that the double is being represented differently between java and php.

> Doubles are not IEEE 754 when writing in the BinaryFormat
> ---------------------------------------------------------
>
>                 Key: THRIFT-644
>                 URL: https://issues.apache.org/jira/browse/THRIFT-644
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (PHP)
>    Affects Versions: 0.1, 0.2, 0.3
>         Environment: PHP 5.3 - Ubuntu 9.10
> Most likely all OSes 
>            Reporter: Jeff Whiting
>         Attachments: Timing.thrift
>
>
> Steps to Repro:
> 1.  Without the PHP thrift extension serialize a struct with a double (note I haven't tested this with the php extension)
> 2. Attempt to read the struct using Java
> Results:
> Java is unable to read the double correctly
> Expected Results:
> Looking at the PHP code in TBinaryProtocol.php the function writeDouble does the following:
> $data = pack('d', $value); 
> According to the PHP documentation (http://php.net/manual/en/function.pack.php)
> 'd' is: double (machine dependent size and representation).
> The double should be IEEE 754 compliant.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (THRIFT-644) Doubles are not IEEE 754 when writing in the BinaryFormat

Posted by "Jeff Whiting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788167#action_12788167 ] 

Jeff Whiting edited comment on THRIFT-644 at 12/9/09 5:18 PM:
--------------------------------------------------------------

I've attached the thrift file we are using.  The values we have set for each property are as follows:

firstClick = 0.14000000000000001332267629550187848508358001708984375
lastClick = 9.25
pageSubmit = 0.520000000000000017763568394002504646778106689453125
clickCount = 43

Just for some background information, we are attempting to move away from the php serialized arrays and to thrift. I've pulled these values directly from the php serialized array we are currently using.

Honestly I don't know enough about the thrift binary format to be able to look at two different binary encodings and tell you what is going on.  

However, I have looked at the java code (TBinaryProtocol.java) and it encodes doubles using Double.doubleToLongBits and according to http://java.sun.com/javase/6/docs/api/java/lang/Double.html#doubleToLongBits%28double%29 it is using a IEEE 754 encoding. Unfortunately php pack function produces a double that is "machine dependent size and representation."  So I'm assuming the problem is that the double is being represented differently between java and php.

As far as $data variable, that is just from the function writeDouble found in TBinaryProtocol.php.  Here is the entire function for more context:

public function writeDouble($value) {
 	$data = pack('d', $value);
 	$this->trans_->write(strrev($data), 8);
 	return 8;
} 

      was (Author: whitingj):
    I've attached the thrift file we are using.  The values we have set for each property are as follows:

firstClick = 0.14000000000000001332267629550187848508358001708984375
lastClick = 9.25
pageSubmit = 0.520000000000000017763568394002504646778106689453125
clickCount = 43

Just for some background information, we are attempting to move away from the php serialized arrays and to thrift. I've pulled these values directly from the php serialized array we are currently using.

Honestly I don't know enough about the thrift binary format to be able to look at two different binary encodings and tell you what is going on.  

However, I have looked at the java code (TBinaryProtocol.java) and it encodes doubles using Double.doubleToLongBits and according to http://java.sun.com/javase/6/docs/api/java/lang/Double.html#doubleToLongBits%28double%29 it is using a IEEE 754 encoding. Unfortunately php pack function produces a double that is "machine dependent size and representation."  So I'm assuming the problem is that the double is being represented differently between java and php.
  
> Doubles are not IEEE 754 when writing in the BinaryFormat
> ---------------------------------------------------------
>
>                 Key: THRIFT-644
>                 URL: https://issues.apache.org/jira/browse/THRIFT-644
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (PHP)
>    Affects Versions: 0.1, 0.2, 0.3
>         Environment: PHP 5.3 - Ubuntu 9.10
> Most likely all OSes 
>            Reporter: Jeff Whiting
>         Attachments: Timing.thrift
>
>
> Steps to Repro:
> 1.  Without the PHP thrift extension serialize a struct with a double (note I haven't tested this with the php extension)
> 2. Attempt to read the struct using Java
> Results:
> Java is unable to read the double correctly
> Expected Results:
> Looking at the PHP code in TBinaryProtocol.php the function writeDouble does the following:
> $data = pack('d', $value); 
> According to the PHP documentation (http://php.net/manual/en/function.pack.php)
> 'd' is: double (machine dependent size and representation).
> The double should be IEEE 754 compliant.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (THRIFT-644) Doubles are not IEEE 754 when writing in the BinaryFormat

Posted by "Jeff Whiting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788167#action_12788167 ] 

Jeff Whiting edited comment on THRIFT-644 at 12/9/09 5:19 PM:
--------------------------------------------------------------

I've attached the thrift file we are using.  The values we have set for each property are as follows:

firstClick = 0.14000000000000001332267629550187848508358001708984375
lastClick = 9.25
pageSubmit = 0.520000000000000017763568394002504646778106689453125
clickCount = 43

Just for some background information, we are attempting to move away from the php serialized arrays and to thrift. I've pulled these values directly from the php serialized array we are currently using.

Honestly I don't know enough about the thrift binary format to be able to look at two different binary encodings and tell you what is going on.  

However, I have looked at the java code (TBinaryProtocol.java) and it encodes doubles using Double.doubleToLongBits and according to http://java.sun.com/javase/6/docs/api/java/lang/Double.html#doubleToLongBits%28double%29 it is using a IEEE 754 encoding. Unfortunately php pack function produces a double that is "machine dependent size and representation."  So I'm assuming the problem is that the double is being represented differently between java and php.

As far as $data variable, that is just from the function writeDouble found in TBinaryProtocol.php.  Here is the entire function for more context:

public function writeDouble($value) {

 	$data = pack('d', $value);

 	$this->trans_->write(strrev($data), 8);

 	return 8;

} 

      was (Author: whitingj):
    I've attached the thrift file we are using.  The values we have set for each property are as follows:

firstClick = 0.14000000000000001332267629550187848508358001708984375
lastClick = 9.25
pageSubmit = 0.520000000000000017763568394002504646778106689453125
clickCount = 43

Just for some background information, we are attempting to move away from the php serialized arrays and to thrift. I've pulled these values directly from the php serialized array we are currently using.

Honestly I don't know enough about the thrift binary format to be able to look at two different binary encodings and tell you what is going on.  

However, I have looked at the java code (TBinaryProtocol.java) and it encodes doubles using Double.doubleToLongBits and according to http://java.sun.com/javase/6/docs/api/java/lang/Double.html#doubleToLongBits%28double%29 it is using a IEEE 754 encoding. Unfortunately php pack function produces a double that is "machine dependent size and representation."  So I'm assuming the problem is that the double is being represented differently between java and php.

As far as $data variable, that is just from the function writeDouble found in TBinaryProtocol.php.  Here is the entire function for more context:

public function writeDouble($value) {
 	$data = pack('d', $value);
 	$this->trans_->write(strrev($data), 8);
 	return 8;
} 
  
> Doubles are not IEEE 754 when writing in the BinaryFormat
> ---------------------------------------------------------
>
>                 Key: THRIFT-644
>                 URL: https://issues.apache.org/jira/browse/THRIFT-644
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (PHP)
>    Affects Versions: 0.1, 0.2, 0.3
>         Environment: PHP 5.3 - Ubuntu 9.10
> Most likely all OSes 
>            Reporter: Jeff Whiting
>         Attachments: Timing.thrift
>
>
> Steps to Repro:
> 1.  Without the PHP thrift extension serialize a struct with a double (note I haven't tested this with the php extension)
> 2. Attempt to read the struct using Java
> Results:
> Java is unable to read the double correctly
> Expected Results:
> Looking at the PHP code in TBinaryProtocol.php the function writeDouble does the following:
> $data = pack('d', $value); 
> According to the PHP documentation (http://php.net/manual/en/function.pack.php)
> 'd' is: double (machine dependent size and representation).
> The double should be IEEE 754 compliant.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-644) Doubles are not IEEE 754 when writing in the BinaryFormat

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788186#action_12788186 ] 

David Reiss commented on THRIFT-644:
------------------------------------

Thanks for the details.  I was actually also looking for the error that Java emits.

> Doubles are not IEEE 754 when writing in the BinaryFormat
> ---------------------------------------------------------
>
>                 Key: THRIFT-644
>                 URL: https://issues.apache.org/jira/browse/THRIFT-644
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (PHP)
>    Affects Versions: 0.1, 0.2, 0.3
>         Environment: PHP 5.3 - Ubuntu 9.10 - 32 bit
> Most likely all OSes 
>            Reporter: Jeff Whiting
>         Attachments: Timing.thrift
>
>
> Steps to Repro:
> 1.  Without the PHP thrift extension serialize a struct with a double (note I haven't tested this with the php extension)
> 2. Attempt to read the struct using Java
> Results:
> Java is unable to read the double correctly
> Expected Results:
> Looking at the PHP code in TBinaryProtocol.php the function writeDouble does the following:
> $data = pack('d', $value); 
> According to the PHP documentation (http://php.net/manual/en/function.pack.php)
> 'd' is: double (machine dependent size and representation).
> The double should be IEEE 754 compliant.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (THRIFT-644) Doubles are not IEEE 754 when writing in the BinaryFormat

Posted by "Jeff Whiting (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-644?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jeff Whiting closed THRIFT-644.
-------------------------------

    Resolution: Cannot Reproduce

There was no problem with the thrift library.

> Doubles are not IEEE 754 when writing in the BinaryFormat
> ---------------------------------------------------------
>
>                 Key: THRIFT-644
>                 URL: https://issues.apache.org/jira/browse/THRIFT-644
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (PHP)
>    Affects Versions: 0.1, 0.2, 0.3
>         Environment: PHP 5.3 - Ubuntu 9.10 - 32 bit
> Most likely all OSes 
>            Reporter: Jeff Whiting
>         Attachments: Timing.thrift
>
>
> Steps to Repro:
> 1.  Without the PHP thrift extension serialize a struct with a double (note I haven't tested this with the php extension)
> 2. Attempt to read the struct using Java
> Results:
> Java is unable to read the double correctly
> Expected Results:
> Looking at the PHP code in TBinaryProtocol.php the function writeDouble does the following:
> $data = pack('d', $value); 
> According to the PHP documentation (http://php.net/manual/en/function.pack.php)
> 'd' is: double (machine dependent size and representation).
> The double should be IEEE 754 compliant.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-644) Doubles are not IEEE 754 when writing in the BinaryFormat

Posted by "Jeff Whiting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788977#action_12788977 ] 

Jeff Whiting commented on THRIFT-644:
-------------------------------------

The tests run fine.  

We found our problem though.  After writing the file to disk in php we were reading from the disk into a string in Java and then attempting to deserialize it.  Obviously putting binary data into a Java string mangles the binary data.

Sorry for submitting a bogus bug and thanks for replying.   

> Doubles are not IEEE 754 when writing in the BinaryFormat
> ---------------------------------------------------------
>
>                 Key: THRIFT-644
>                 URL: https://issues.apache.org/jira/browse/THRIFT-644
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (PHP)
>    Affects Versions: 0.1, 0.2, 0.3
>         Environment: PHP 5.3 - Ubuntu 9.10 - 32 bit
> Most likely all OSes 
>            Reporter: Jeff Whiting
>         Attachments: Timing.thrift
>
>
> Steps to Repro:
> 1.  Without the PHP thrift extension serialize a struct with a double (note I haven't tested this with the php extension)
> 2. Attempt to read the struct using Java
> Results:
> Java is unable to read the double correctly
> Expected Results:
> Looking at the PHP code in TBinaryProtocol.php the function writeDouble does the following:
> $data = pack('d', $value); 
> According to the PHP documentation (http://php.net/manual/en/function.pack.php)
> 'd' is: double (machine dependent size and representation).
> The double should be IEEE 754 compliant.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (THRIFT-644) Doubles are not IEEE 754 when writing in the BinaryFormat

Posted by "Jeff Whiting (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-644?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jeff Whiting updated THRIFT-644:
--------------------------------

    Environment: 
PHP 5.3 - Ubuntu 9.10 - 32 bit
Most likely all OSes 

  was:
PHP 5.3 - Ubuntu 9.10
Most likely all OSes 


> Doubles are not IEEE 754 when writing in the BinaryFormat
> ---------------------------------------------------------
>
>                 Key: THRIFT-644
>                 URL: https://issues.apache.org/jira/browse/THRIFT-644
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (PHP)
>    Affects Versions: 0.1, 0.2, 0.3
>         Environment: PHP 5.3 - Ubuntu 9.10 - 32 bit
> Most likely all OSes 
>            Reporter: Jeff Whiting
>         Attachments: Timing.thrift
>
>
> Steps to Repro:
> 1.  Without the PHP thrift extension serialize a struct with a double (note I haven't tested this with the php extension)
> 2. Attempt to read the struct using Java
> Results:
> Java is unable to read the double correctly
> Expected Results:
> Looking at the PHP code in TBinaryProtocol.php the function writeDouble does the following:
> $data = pack('d', $value); 
> According to the PHP documentation (http://php.net/manual/en/function.pack.php)
> 'd' is: double (machine dependent size and representation).
> The double should be IEEE 754 compliant.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-644) Doubles are not IEEE 754 when writing in the BinaryFormat

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788192#action_12788192 ] 

David Reiss commented on THRIFT-644:
------------------------------------

I can't reproduce this.  I'll try too clean up the Java test server and php test client so you can run them easily, but I hacked them into working and saw a double passed back and forth with no problems.  I am on 32-bit Ubuntu 9.04

> Doubles are not IEEE 754 when writing in the BinaryFormat
> ---------------------------------------------------------
>
>                 Key: THRIFT-644
>                 URL: https://issues.apache.org/jira/browse/THRIFT-644
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (PHP)
>    Affects Versions: 0.1, 0.2, 0.3
>         Environment: PHP 5.3 - Ubuntu 9.10 - 32 bit
> Most likely all OSes 
>            Reporter: Jeff Whiting
>         Attachments: Timing.thrift
>
>
> Steps to Repro:
> 1.  Without the PHP thrift extension serialize a struct with a double (note I haven't tested this with the php extension)
> 2. Attempt to read the struct using Java
> Results:
> Java is unable to read the double correctly
> Expected Results:
> Looking at the PHP code in TBinaryProtocol.php the function writeDouble does the following:
> $data = pack('d', $value); 
> According to the PHP documentation (http://php.net/manual/en/function.pack.php)
> 'd' is: double (machine dependent size and representation).
> The double should be IEEE 754 compliant.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (THRIFT-644) Doubles are not IEEE 754 when writing in the BinaryFormat

Posted by "Jeff Whiting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788167#action_12788167 ] 

Jeff Whiting edited comment on THRIFT-644 at 12/9/09 5:20 PM:
--------------------------------------------------------------

I've attached the thrift file we are using.  The values we have set for each property are as follows:

firstClick = 0.14000000000000001332267629550187848508358001708984375
lastClick = 9.25
pageSubmit = 0.520000000000000017763568394002504646778106689453125
clickCount = 43

Just for some background information, we are attempting to move away from the php serialized arrays and to thrift. I've pulled these values directly from the php serialized array we are currently using.

Honestly I don't know enough about the thrift binary format to be able to look at two different binary encodings and tell you what is going on.  

However, I have looked at the java code (TBinaryProtocol.java) and it encodes doubles using Double.doubleToLongBits and according to http://java.sun.com/javase/6/docs/api/java/lang/Double.html#doubleToLongBits%28double%29 it is using a IEEE 754 encoding. Unfortunately php pack function produces a double that is "machine dependent size and representation."  So I'm assuming the problem is that the double is being represented differently between java and php.

As far as $data variable, that is just from the function writeDouble found in TBinaryProtocol.php.  Here is the entire function for more context:


public function writeDouble($value) {
 	$data = pack('d', $value);
 	$this->trans_->write(strrev($data), 8);
 	return 8;
} 


      was (Author: whitingj):
    I've attached the thrift file we are using.  The values we have set for each property are as follows:

firstClick = 0.14000000000000001332267629550187848508358001708984375
lastClick = 9.25
pageSubmit = 0.520000000000000017763568394002504646778106689453125
clickCount = 43

Just for some background information, we are attempting to move away from the php serialized arrays and to thrift. I've pulled these values directly from the php serialized array we are currently using.

Honestly I don't know enough about the thrift binary format to be able to look at two different binary encodings and tell you what is going on.  

However, I have looked at the java code (TBinaryProtocol.java) and it encodes doubles using Double.doubleToLongBits and according to http://java.sun.com/javase/6/docs/api/java/lang/Double.html#doubleToLongBits%28double%29 it is using a IEEE 754 encoding. Unfortunately php pack function produces a double that is "machine dependent size and representation."  So I'm assuming the problem is that the double is being represented differently between java and php.

As far as $data variable, that is just from the function writeDouble found in TBinaryProtocol.php.  Here is the entire function for more context:

<pre>
public function writeDouble($value) {
 	$data = pack('d', $value);
 	$this->trans_->write(strrev($data), 8);
 	return 8;
} 
</pre>
  
> Doubles are not IEEE 754 when writing in the BinaryFormat
> ---------------------------------------------------------
>
>                 Key: THRIFT-644
>                 URL: https://issues.apache.org/jira/browse/THRIFT-644
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (PHP)
>    Affects Versions: 0.1, 0.2, 0.3
>         Environment: PHP 5.3 - Ubuntu 9.10
> Most likely all OSes 
>            Reporter: Jeff Whiting
>         Attachments: Timing.thrift
>
>
> Steps to Repro:
> 1.  Without the PHP thrift extension serialize a struct with a double (note I haven't tested this with the php extension)
> 2. Attempt to read the struct using Java
> Results:
> Java is unable to read the double correctly
> Expected Results:
> Looking at the PHP code in TBinaryProtocol.php the function writeDouble does the following:
> $data = pack('d', $value); 
> According to the PHP documentation (http://php.net/manual/en/function.pack.php)
> 'd' is: double (machine dependent size and representation).
> The double should be IEEE 754 compliant.  

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.