Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Pack floats, doubles in big-endian order

Cassandra expects data in big-endian order, but php apparently
uses little-endian order for floats and doubles on x86 and x64.

Fixes #90
  • Loading branch information...
commit b07a236c04d98158163d2bbef201bd067b39901d 1 parent 849282c
@thobbs authored
View
4 lib/phpcassa/Schema/DataType/DoubleType.php
@@ -13,11 +13,11 @@ class DoubleType extends CassandraType implements Serialized
public function pack($value, $is_name=true, $slice_end=null, $is_data=false) {
if ($is_name && $is_data)
$value = unserialize($value);
- return pack("d", $value);
+ return strrev(pack("d", $value));
}
public function unpack($data, $is_name=true) {
- $value = current(unpack("d", $data));
+ $value = current(unpack("d", strrev($data)));
if ($is_name) {
return serialize($value);
} else {
View
4 lib/phpcassa/Schema/DataType/FloatType.php
@@ -13,11 +13,11 @@ class FloatType extends CassandraType implements Serialized
public function pack($value, $is_name=true, $slice_end=null, $is_data=false) {
if ($is_name && $is_data)
$value = unserialize($value);
- return pack("f", $value);
+ return strrev(pack("f", $value));
}
public function unpack($data, $handle_serialize=true) {
- $value = current(unpack("f", $data));
+ $value = current(unpack("f", strrev($data)));
if ($handle_serialize) {
return serialize($value);
} else {
Please sign in to comment.
Something went wrong with that request. Please try again.