From db781a4ba366852b7cda09ab44174d8723da163d Mon Sep 17 00:00:00 2001 From: joachim Date: Mon, 22 Apr 2019 10:20:12 -0400 Subject: [PATCH] Issue #662692 by joachim, hanoii, ShaneOnABike, lunazoid, 5t4rdu5t: strange decimal precision error on floating numeric fields. --- handlers/views_handler_field_numeric.inc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/handlers/views_handler_field_numeric.inc b/handlers/views_handler_field_numeric.inc index b48256fc..acb5a823 100644 --- a/handlers/views_handler_field_numeric.inc +++ b/handlers/views_handler_field_numeric.inc @@ -101,12 +101,13 @@ class views_handler_field_numeric extends views_handler_field { $value = number_format($value, $this->options['precision'], $this->options['decimal'], $this->options['separator']); } else { - $remainder = abs($value) - intval(abs($value)); + $point_position = strpos($value, '.'); + $remainder = ($point_position === FALSE) ? '' : substr($value, $point_position + 1); $value = $value > 0 ? floor($value) : ceil($value); $value = number_format($value, 0, '', $this->options['separator']); if ($remainder) { // The substr may not be locale safe. - $value .= $this->options['decimal'] . substr($remainder, 2); + $value .= $this->options['decimal'] . $remainder; } }