<?php
declare(strict_types=1);
//the only right example
var_dump(
bcadd('17.123', '19.456', 10)
);
//can't do this (changes are only in the first part), just all the cases that are inappropriate for bcmath
//whitespace
var_dump(
bcadd('17 .123', '19.456', 10)
);
//comma
var_dump(
bcadd('17,123', '19.456', 10)
);
//comma as thousands separator
var_dump(
bcadd('1,700.123', '19.456', 10)
);
//changing locale to a country which uses decimal comma, see this https://bugs.php.net/bug.php?id=55160
$currentLocale = setlocale(LC_ALL, 0);
setlocale(LC_ALL, "en_DK.UTF-8");
var_dump(
bcadd('1,700.123', '19.456', 10)
);
setlocale(LC_ALL, $currentLocale);
//exponential numbers
var_dump(
bcadd('17e123', '19.456', 10)
);
//using words
var_dump(
bcadd('hello', '19.456', 10)
);