Skip to content

Commit cabcafa

Browse files
authored
Merge pull request #4 from fruitcake/add-rounding-tests
Add rounding tests
2 parents 127f58a + d27a148 commit cabcafa

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

tests/DecimalTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,8 @@ public static function provideMultiply()
298298
[0.1, 2, '0.20'],
299299
['2', '2', '4.00'],
300300
['2.0', '2', '4', 0],
301+
['1.0', '17.40', '17.40', 2],
302+
['17.40', '1.00', '17.40', 2],
301303
];
302304
}
303305

@@ -397,6 +399,18 @@ public function testChaining()
397399
$this->assertTrue($c->isZeroOrNegative());
398400
}
399401

402+
public function testPreservesInternalPrecision()
403+
{
404+
$this->markTestSkipped('Higher internal precision is currently not preserved');
405+
406+
$a = decimal('2.30')->multiply('0.75')->toString();
407+
$this->assertEquals('1.73', $a);
408+
409+
$b = decimal('2.30')->sub(decimal('2.30')->multiply('0.25'))->toString();
410+
$this->assertEquals('1.73', $b);
411+
$this->assertEquals($a, $b);
412+
}
413+
400414
public function testDecimalIsNotEqual()
401415
{
402416
$this->assertTrue(decimal(3)->notEquals(5));

0 commit comments

Comments
 (0)