Rerun of /includes/ui/ui_view.inc
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 8 Feb 2012 00:00:11 +0000 (01:00 +0100)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 8 Feb 2012 00:00:11 +0000 (01:00 +0100)
includes/ui/ui_view.inc

index 00c0cd0c9d64f3ad4f20d5b80c8beb47621e342d..e366af368f085e0aee7051d550782f4ae24bb8ec 100644 (file)
@@ -774,14 +774,8 @@ function price_in_words($amount, $document=0)
        if ($dec > 0)
        {
                $divisor = pow(10, $dec);
-               // algorithm rewritten due to a bug in sprintf (wrong with frac, 29, 57 and more).
         $frac = round2($amount - floor($amount), $dec) * $divisor;
-        for ($div = $divisor / 10; $div > 1; $div /= 10)
-        {
-               if ($frac < $div)
-                       $frac = "0" . $frac;
-        }              
-               //$frac = sprintf("%0{$dec}d", $frac);
+               $frac = sprintf("%0{$dec}d", round2($frac, 0));
                $and = _("and");
        $frac = " $and $frac/$divisor";
     }