From fbc3fd00808802cecca7d241c7fe5e4a82c4ff25 Mon Sep 17 00:00:00 2001 From: Adrian Gibbons Date: Sun, 16 Aug 2015 09:06:50 +0800 Subject: [PATCH] uint to sint on 64bit machines --- php-FIT-File-Analysis.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/php-FIT-File-Analysis.php b/php-FIT-File-Analysis.php index 1174a83..babe867 100644 --- a/php-FIT-File-Analysis.php +++ b/php-FIT-File-Analysis.php @@ -389,7 +389,7 @@ class phpFITFileAnalysis { 0 => 255, // 0xFF 1 => 127, // 0x7F 2 => 255, // 0xFF - 131 => 32767, // 0x7FFF + 131 => 65535, // 0xFFFF - manually convert uint16 to sint16 in fix_data() 132 => 65535, // 0xFFFF 133 => 4294967295, // 0xFFFFFFFF - manually convert uint32 to sint32 in fix_data() 134 => 4294967295, // 0xFFFFFFFF @@ -806,6 +806,10 @@ private function fix_data($options) { $field_name = $this->data_mesg_info[$mesg['global_mesg_num']]['field_defns'][$field['field_definition_number']]['field_name']; if(is_array($this->data_mesgs[$mesg_name][$field_name])) { foreach($this->data_mesgs[$mesg_name][$field_name] as &$v) { + if(PHP_INT_SIZE === 8 && $v >= 0x7FFFFFFF) { + $v -= 0x100000000; + } + if($v >= 0x7FFFFFFF) { $v = -1 * ($v - 0x7FFFFFFF); }