Skip to content

Commit

Permalink
Round fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zgrguric committed Mar 28, 2024
1 parent 4c256b7 commit 9d212f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Utilities/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static function currencyToSymbol(string $currencycode, string $malformedU
//let interest_after_year = precision(Math.pow(Math.E, (interest_start+year_seconds - interest_start) / interest_period), 14);
$interest_after_year = \pow(\exp(1), $year_seconds / $interest_period);
$interest = ($interest_after_year*100) - 100;
return $code.' ('.$interest.'% pa)';
return $code.' ('.round($interest,1).'% pa)';
}

$r = \trim(\hex2bin($currencycode));
Expand Down
4 changes: 4 additions & 0 deletions tests/Unit/UtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ class XRPLParserUtilUtilTest extends TestCase
public function testConvertCurrencyToSymbolDemurrage()
{
$this->assertEquals('XAU (-0.5% pa)',Util::currencyToSymbol('0158415500000000C1F76FF6ECB0BAC600000000'));
$this->assertEquals('XAU (-0.5% pa)',Util::currencyToSymbol('015841551A748AD2C1F76FF6ECB0CCCD00000000'));
$this->assertEquals('LOT (-99% pa)',Util::currencyToSymbol('014C4F5400000000C15A1F74D9006ADA00000000'));
$this->assertEquals('CNY (-60% pa)',Util::currencyToSymbol('01434E5900000000C180694BFF0A625D00000000'));

}

public function testConvertCurrencyToSymbolISO()
Expand Down

0 comments on commit 9d212f1

Please sign in to comment.