Skip to content

Commit

Permalink
Fix floating point type (majkel89#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
krzyc committed Dec 12, 2019
1 parent 483f27e commit d8c4b5e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,9 @@ protected function createField($data) {
$field = Field::create($data['t']);
$field->setName(rtrim($data['n']));
$field->setLength($data['ll']);
if ($data['t'] == Field::TYPE_NUMERIC && isset($data['dd'])) {
$field->setDecimalCount(2);
}
return $field;
}

Expand Down
2 changes: 1 addition & 1 deletion src/field/NumericField.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function fromData($data) {
if (!$this->getDecimalCount()) {
return (integer)substr($data, 0, $this->getLength());
} else {
return (float)number_format(substr($data, 0, $this->getLength()), $this->getDecimalCount(), '.', '');
return (float)number_format((float)substr($data, 0, $this->getLength()), $this->getDecimalCount(), '.', '');
}
}

Expand Down

0 comments on commit d8c4b5e

Please sign in to comment.