diff --git a/src/Sav/Record/Info/MachineFloatingPoint.php b/src/Sav/Record/Info/MachineFloatingPoint.php index a73e97c..8a2472f 100644 --- a/src/Sav/Record/Info/MachineFloatingPoint.php +++ b/src/Sav/Record/Info/MachineFloatingPoint.php @@ -52,15 +52,15 @@ public function read(Buffer $buffer) public function write(Buffer $buffer) { - if ($this->sysmis === 0.0) { + if (!isset($this->sysmis)) { $this->sysmis = -PHP_FLOAT_MAX; } - if ($this->highest === 0.0) { + if (!isset($this->highest)) { $this->highest = PHP_FLOAT_MAX; } - if ($this->lowest === 0.0) { + if (!isset($this->lowest)) { $this->lowest = -PHP_FLOAT_MAX; } diff --git a/tests/MachineFloatingPointTest.php b/tests/MachineFloatingPointTest.php index 2448985..b0e9fc4 100644 --- a/tests/MachineFloatingPointTest.php +++ b/tests/MachineFloatingPointTest.php @@ -24,12 +24,12 @@ public function provider() ], [ [], - // -1.7976931348623E+308 php min double - // 1.7976931348623E+308 php max double + // -1.7976931348623E+308 php min double -PHP_FLOAT_MAX + // 1.7976931348623E+308 php max double PHP_FLOAT_MAX [ - 'sysmis' => -1.7976931348623158E+308, - 'highest' => 1.7976931348623158E+308, - 'lowest' => -1.7976931348623158E+308, + 'sysmis' => -PHP_FLOAT_MAX, + 'highest' => PHP_FLOAT_MAX, + 'lowest' => -PHP_FLOAT_MAX, ], ], ]; @@ -54,10 +54,8 @@ public function testWriteRead(array $attributes, array $expected) $read = MachineFloatingPoint::fill($buffer); $this->assertEquals(40, $buffer->position()); foreach ($expected as $key => $value) { - $expected = 0; - $actual = @bcsub($value, $read->{$key}); $msg = "Wrong value received for '$key', expected '$value', got '{$read->{$key}}'"; - $this->assertEquals($expected, $actual, $msg); + $this->assertEquals($value, $read->{$key}, $msg); } } }