diff options
author | P. J. McDermott <pj@pehjota.net> | 2017-01-17 15:26:43 (EST) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2017-01-17 15:26:43 (EST) |
commit | 2e07de44d85e36d42b87b582f60c2385c2b3b091 (patch) | |
tree | 96c3425ea0c9dd3b880d7d61983cd84780f527d7 /lib | |
parent | 7ef13908bd7b9346f932b312ace5eff1a5dc2cba (diff) | |
download | Math-Decimal-FastPP-2e07de44d85e36d42b87b582f60c2385c2b3b091.zip Math-Decimal-FastPP-2e07de44d85e36d42b87b582f60c2385c2b3b091.tar.gz Math-Decimal-FastPP-2e07de44d85e36d42b87b582f60c2385c2b3b091.tar.bz2 |
dadd(), dmul(), drhtz(), drhfz(): Use char classes for decimal points, not escapes
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Math/Decimal/FastPP.pm | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/Math/Decimal/FastPP.pm b/lib/Math/Decimal/FastPP.pm index bc5ffbe..3fe00c7 100644 --- a/lib/Math/Decimal/FastPP.pm +++ b/lib/Math/Decimal/FastPP.pm @@ -94,8 +94,8 @@ Adds C<$a> and C<$b> and returns their sum. sub dadd { - my ($ai, $af) = split(/\./, $_[0]); - my ($bi, $bf) = split(/\./, $_[1]); + my ($ai, $af) = split(/[.]/, $_[0]); + my ($bi, $bf) = split(/[.]/, $_[1]); $af ||= ''; $bf ||= ''; my $ae = length($af); @@ -128,8 +128,8 @@ Multiplies C<$a> and C<$b> and returns their product. sub dmul { - my ($ai, $af) = split(/\./, $_[0]); - my ($bi, $bf) = split(/\./, $_[1]); + my ($ai, $af) = split(/[.]/, $_[0]); + my ($bi, $bf) = split(/[.]/, $_[1]); $af ||= ''; $bf ||= ''; my $as = $ai . $af; @@ -162,7 +162,7 @@ of significant digits right of the radix point. sub drhtz { - my ($ai, $af, $ad) = $_[0] =~ m/^(-?\d*)\.(\d{$_[1]})(\d*)$/ or return; + my ($ai, $af, $ad) = $_[0] =~ m/^(-?\d*)[.](\d{$_[1]})(\d*)$/ or return; my $as = $ai . $af; if ($as >= 0) { if ($ad > '5' . '0' x (length($ad) - 1)) { ++$as; } @@ -193,7 +193,7 @@ of significant digits right of the radix point. sub drhfz { - my ($ai, $af, $ad) = $_[0] =~ m/^(-?\d*)\.(\d{$_[1]})(\d*)$/ or return; + my ($ai, $af, $ad) = $_[0] =~ m/^(-?\d*)[.](\d{$_[1]})(\d*)$/ or return; my $as = $ai . $af; if ($as >= 0) { if ($ad >= '5' . '0' x (length($ad) - 1)) { ++$as; } |