money: Problems with string casting and locales that use comma as separator

Triying to do something similar to this:

$money = Money::EUR(100); 
$percentage = $money->multiply(10 / 100);
$result = $money->subtract($percentage);

but it returns 0€ for $percentage. Any clue? The system does have the bcmath extension loaded.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 20 (10 by maintainers)

Commits related to this issue

Most upvoted comments

@Surt PR #361 will solve the issue.

Cool. Thanks.

        printf('%.8g', 1.3);  // "1,3"
        printf('%.8G', 1.3); // "1,3"
        printf('%.8F', 1.3); // "1.3"

http://php.net/manual/en/function.sprintf.php F - the argument is treated as a float, and presented as a floating-point number (non-locale aware). Available since PHP 5.0.3.

so, “%.8F” seems to be the way to go.

@Surt I will take care of this. You can expect fixes tomorrow.