Skip to content

Commit

Permalink
uint to sint on 64bit machines
Browse files Browse the repository at this point in the history
  • Loading branch information
adriangibbons committed Aug 16, 2015
1 parent f7dba2b commit fbc3fd0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion php-FIT-File-Analysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit fbc3fd0

Please sign in to comment.