Skip to content

Commit

Permalink
Fix for rounding issue when formatting whole number (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x686578 authored and thiemowmde committed Oct 11, 2016
1 parent a408b29 commit afd6523
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/Formatters/GeoCoordinateFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,8 @@ private function getSignificantDigits( $unitsPerDegree, $degreePrecision ) {
*/
private function formatNumber( $number, $digits = 0 ) {
//TODO: use NumberLocalizer
return sprintf( $digits > 0
? '%.' . (int)$digits . 'F'
: '%d', $number );
$digits = $digits < 0 ? 0 : $digits;
return sprintf( '%.' . (int)$digits . 'F', $number );
}

}
2 changes: 1 addition & 1 deletion tests/unit/Formatters/GeoCoordinateFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public function decimalMinuteNotationProvider() {
'ten minutes' => array(
new LatLongValue( -55.755786, 37.25633 ),
10.0/60,
'-55° 49\', 37° 19\''
'-55° 50\', 37° 20\''
),
'fifty minutes' => array(
new LatLongValue( -55.755786, 37.25633 ),
Expand Down

0 comments on commit afd6523

Please sign in to comment.