| 1 | package File::Rsync::Mirror::Recentfile::FakeBigFloat; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # use warnings; | ||||||||||||||||||||||||||||
| 4 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 14 | ▶ | use Data::Float qw(nextup); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | # _bigfloat | ||||||||||||||||||||||||||||
| 8 | sub _bigfloatcmp ($$); | ||||||||||||||||||||||||||||
| 9 | sub _bigfloatge ($$); | ||||||||||||||||||||||||||||
| 10 | sub _bigfloatgt ($$); | ||||||||||||||||||||||||||||
| 11 | sub _bigfloatle ($$); | ||||||||||||||||||||||||||||
| 12 | sub _bigfloatlt ($$); | ||||||||||||||||||||||||||||
| 13 | sub _bigfloatmax ($$); | ||||||||||||||||||||||||||||
| 14 | sub _bigfloatmin ($$); | ||||||||||||||||||||||||||||
| 15 | sub _increase_a_bit ($;$); | ||||||||||||||||||||||||||||
| 16 | sub _increase_a_bit_tail ($$); | ||||||||||||||||||||||||||||
| 17 | sub _my_sprintf_float ($); | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =encoding utf-8 | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | =head1 NAME | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | File::Rsync::Mirror::Recentfile::FakeBigFloat - pseudo bigfloat support | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | =cut | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 14 | ▶ | use version; our $VERSION = qv('0.0.8'); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 14 | ▶ | use Exporter; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | 14 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | 14 | our %EXPORT_TAGS; | |||||||||||||||||||||||||||
| 32 | 14 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||
| 33 | _bigfloatcmp | ||||||||||||||||||||||||||||
| 34 | _bigfloatge | ||||||||||||||||||||||||||||
| 35 | _bigfloatgt | ||||||||||||||||||||||||||||
| 36 | _bigfloatle | ||||||||||||||||||||||||||||
| 37 | _bigfloatlt | ||||||||||||||||||||||||||||
| 38 | _bigfloatmax | ||||||||||||||||||||||||||||
| 39 | _bigfloatmin | ||||||||||||||||||||||||||||
| 40 | _increase_a_bit | ||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||
| 42 | 14 | $EXPORT_TAGS{all} = \@EXPORT_OK; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | use File::Rsync::Mirror::Recentfile::FakeBigFloat qw(:all); | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =head1 ONLY INTERNAL FUNCTIONS | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | These functions are not part of a public interface and can be | ||||||||||||||||||||||||||||
| 51 | changed and go away any time without prior notice. | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | We treat strings that look like floating point numbers. If the native | ||||||||||||||||||||||||||||
| 56 | floating point support is good enough we use it. If it isn't we make | ||||||||||||||||||||||||||||
| 57 | sure no two unequal numbers are treated the same and vice versa. Only | ||||||||||||||||||||||||||||
| 58 | comparison operators are supported, no other math. | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | =head1 EXPORT | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | All functions are exported in the C<:all> tag. | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | =head2 _bigfloatcmp ( $l, $r ) | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | Cmp function for floating point numbers that have a larger significand | ||||||||||||||||||||||||||||
| 67 | than can be handled by native perl floats. | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =cut | ||||||||||||||||||||||||||||
| 70 | 40332 | ▶ | sub _bigfloatcmp ($$) { | ||||||||||||||||||||||||||
|
Subroutine
_bigfloatcmp: called CC=16 SCAR=29.6
| |||||||||||||||||||||||||||||
| 71 | # my($l,$r) = @_; | ||||||||||||||||||||||||||||
| 72 | 40332 | ▶ | unless (defined $_[0] and defined $_[1]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $_[0] and defined $_[1]
MC/DC0%0/2
defined $_[0] and defined $_[1]
defined $_[0]
defined $_[1]
Truth table33%1/3
A and B
A= defined $_[0]B= defined $_[1]
| |||||||||||||||||||||||||||||
| 73 | 0 | require Carp; | |||||||||||||||||||||||||||
| 74 | 0 | for ($_[0],$_[1]) { | |||||||||||||||||||||||||||
| 75 | 0 | ▶ | $_ = defined $_ ? $_ : "UNDEF"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | 0 | Carp::confess("_bigfloatcmp called with l[$_[0]]r[$_[1]]: but both must be defined"); | |||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | # unequal is much more frequent than equal but let's get rid of these | ||||||||||||||||||||||||||||
| 80 | 40332 | ▶ | return 0 if $_[0] eq $_[1]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 35796 | my $can_rely_on_native = 0; | |||||||||||||||||||||||||||
| 82 | 35796 | ▶ | if ($_[0] =~ /\./ || $_[1] =~ /\./) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_[0] =~ /\./ or $_[1] =~ /\./
MC/DC100%2/2
$_[0] =~ /\./ or $_[1] =~ /\./
$_[0] =~ /\./
$_[1] =~ /\./
Truth table100%3/3
A or B
A= $_[0] =~ /\./B= $_[1] =~ /\./
| |||||||||||||||||||||||||||||
| 83 | # if one is a float, both must be, otherwise perl gets it wrong (see test) | ||||||||||||||||||||||||||||
| 84 | 35740 | for ($_[0], $_[1]){ | |||||||||||||||||||||||||||
| 85 | 71480 | ▶ | $_ .= ".0" unless /\./; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | 35740 | ▶ | return 1 if $_[0] - $_[1] > 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | 30496 | ▶ | return -1 if $_[0] - $_[1] < -1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | } else { | ||||||||||||||||||||||||||||
| 90 | 56 | $can_rely_on_native = 1; # can we? | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | #### XXX bug in some perls, we cannot trust native comparison on floating point values: | ||||||||||||||||||||||||||||
| 93 | #### see Todo file entry on 2009-03-15 | ||||||||||||||||||||||||||||
| 94 | 26173 | my $native = $_[0] <=> $_[1]; | |||||||||||||||||||||||||||
| 95 | 26173 | ▶ | return $native if $can_rely_on_native && $native != 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$can_rely_on_native and $native != 0
MC/DC50%1/2
$can_rely_on_native and $native != 0
$can_rely_on_native
$native != 0
Truth table66%2/3
A and B
A= $can_rely_on_nativeB= $native != 0
| |||||||||||||||||||||||||||||
| 96 | 26117 | ▶ | $_[0] =~ s/^/0/ while index($_[0],".") < index($_[1],"."); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 26117 | ▶ | $_[1] =~ s/^/0/ while index($_[1],".") < index($_[0],"."); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 26117 | $_[0] cmp $_[1]; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | =head2 _bigfloatge ( $l, $r ) | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | Same for ge | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | =cut | ||||||||||||||||||||||||||||
| 106 | 27855 | ▶ | sub _bigfloatge ($$) { | ||||||||||||||||||||||||||
|
Subroutine
_bigfloatge: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 107 | 27855 | _bigfloatcmp($_[0],$_[1]) >= 0; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | =head2 _bigfloatgt ( $l, $r ) | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | Same for gt | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =cut | ||||||||||||||||||||||||||||
| 115 | 4262 | ▶ | sub _bigfloatgt ($$) { | ||||||||||||||||||||||||||
|
Subroutine
_bigfloatgt: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 116 | 4262 | _bigfloatcmp($_[0],$_[1]) > 0; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =head2 _bigfloatle ( $l, $r ) | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | Same for lt | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | =cut | ||||||||||||||||||||||||||||
| 124 | 305 | ▶ | sub _bigfloatle ($$) { | ||||||||||||||||||||||||||
|
Subroutine
_bigfloatle: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 125 | 305 | _bigfloatcmp($_[0],$_[1]) <= 0; | |||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | =head2 _bigfloatlt ( $l, $r ) | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | Same for lt | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | =cut | ||||||||||||||||||||||||||||
| 133 | 7682 | ▶ | sub _bigfloatlt ($$) { | ||||||||||||||||||||||||||
|
Subroutine
_bigfloatlt: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 134 | 7682 | _bigfloatcmp($_[0],$_[1]) < 0; | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | =head2 _bigfloatmax ( $l, $r ) | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | Same for max (of two arguments) | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | =cut | ||||||||||||||||||||||||||||
| 142 | 201 | ▶ | sub _bigfloatmax ($$) { | ||||||||||||||||||||||||||
|
Subroutine
_bigfloatmax: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 143 | 201 | my($l,$r) = @_; | |||||||||||||||||||||||||||
| 144 | 201 | ▶ | return _bigfloatcmp($l,$r) >= 0 ? $l : $r; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | =head2 _bigfloatmin ( $l, $r ) | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | Same for min (of two arguments) | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | =cut | ||||||||||||||||||||||||||||
| 152 | 27 | ▶ | sub _bigfloatmin ($$) { | ||||||||||||||||||||||||||
|
Subroutine
_bigfloatmin: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 153 | 27 | my($l,$r) = @_; | |||||||||||||||||||||||||||
| 154 | 27 | ▶ | return _bigfloatcmp($l,$r) <= 0 ? $l : $r; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | =head2 $big = _increase_a_bit ( $l, $r ) | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | =head2 $big = _increase_a_bit ( $n ) | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | The first form calculates a string that is between the two numbers, | ||||||||||||||||||||||||||||
| 162 | closer to $l to prevent rounding effects towards $r. The second form | ||||||||||||||||||||||||||||
| 163 | calculates the second number itself based on nextup() in | ||||||||||||||||||||||||||||
| 164 | L<Data::Float>. | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | =cut | ||||||||||||||||||||||||||||
| 167 | 75 | ▶ | sub _my_sprintf_float ($) { | ||||||||||||||||||||||||||
|
Subroutine
_my_sprintf_float: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 168 | 75 | my($x) = @_; | |||||||||||||||||||||||||||
| 169 | 75 | my $r; | |||||||||||||||||||||||||||
| 170 | 75 | require Config; | |||||||||||||||||||||||||||
| 171 | 75 | ▶ | my $nvsize = $Config::Config{nvsize} || 8; | ||||||||||||||||||||||||||
|
Condition50%1/2
$Config::Config{'nvsize'} || 8
MC/DC0%0/1
$Config::Config{'nvsize'} || 8
$Config::Config{'nvsize'}
Truth table50%1/2
A
A= $Config::Config{'nvsize'}
| |||||||||||||||||||||||||||||
| 172 | 75 | my $lom = 2*$nvsize; # "length of mantissa": nextup needs more digits | |||||||||||||||||||||||||||
| 173 | 75 | NORMALIZE: while () { | |||||||||||||||||||||||||||
| 174 | 153 | my $sprintf = "%." . $lom . "f"; | |||||||||||||||||||||||||||
| 175 | 153 | $r = sprintf $sprintf, $x; | |||||||||||||||||||||||||||
| 176 | 153 | ▶ | if ($r =~ /\.\d+0$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 177 | 75 | last NORMALIZE; | |||||||||||||||||||||||||||
| 178 | } else { | ||||||||||||||||||||||||||||
| 179 | 78 | $lom *= 2; | |||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | 75 | $r =~ s/(\d)0+$/$1/; | |||||||||||||||||||||||||||
| 183 | 75 | return $r; | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | 39 | ▶ | sub _increase_a_bit ($;$) { | ||||||||||||||||||||||||||
|
Subroutine
_increase_a_bit: called CC=9 SCAR=22.9
| |||||||||||||||||||||||||||||
| 186 | 39 | my($l,$r) = @_; | |||||||||||||||||||||||||||
| 187 | 39 | ▶ | unless (defined $l) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | 0 | die "Alert: _increase_a_bit called with undefined first argument"; | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | 39 | ▶ | if (defined $r){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 191 | 3 | ▶ | if ($r eq $l){ | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 192 | 0 | die "Alert: _increase_a_bit called with identical arguments"; | |||||||||||||||||||||||||||
| 193 | } elsif ($r > int($l)+1) { | ||||||||||||||||||||||||||||
| 194 | 0 | $r = int($l)+1; | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | } else { | ||||||||||||||||||||||||||||
| 197 | 36 | $r = _my_sprintf_float(Data::Float::nextup($l)); | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | 39 | my $ret; | |||||||||||||||||||||||||||
| 200 | 39 | ▶ | if ($l == $r) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 201 | } else { | ||||||||||||||||||||||||||||
| 202 | # native try | ||||||||||||||||||||||||||||
| 203 | 39 | my $try = _my_sprintf_float(($l+$r)/2); | |||||||||||||||||||||||||||
| 204 | 39 | ▶ | if (_bigfloatlt($l,$try) && _bigfloatlt($try,$r) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
&_bigfloatlt($l, $try) and &_bigfloatlt($try, $r)
MC/DC100%2/2
&_bigfloatlt($l, $try) and &_bigfloatlt($try, $r)
&_bigfloatlt($l, $try)
&_bigfloatlt($try, $r)
Truth table100%3/3
A and B
A= &_bigfloatlt($l, $try)B= &_bigfloatlt($try, $r)
| |||||||||||||||||||||||||||||
| 205 | 8 | $ret = $try; | |||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | 39 | ▶ | return $ret if $ret; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | 31 | return _increase_a_bit_tail($l,$r); | |||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||
| 211 | 31 | ▶ | sub _increase_a_bit_tail ($$) { | ||||||||||||||||||||||||||
|
Subroutine
_increase_a_bit_tail: called CC=13 SCAR=25.7
| |||||||||||||||||||||||||||||
| 212 | 31 | my($l,$r) = @_; | |||||||||||||||||||||||||||
| 213 | 31 | my $ret; | |||||||||||||||||||||||||||
| 214 | 31 | for ($l, $r){ | |||||||||||||||||||||||||||
| 215 | 62 | ▶ | $_ .= ".0" unless /\./; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | 31 | ▶ | $l =~ s/^/0/ while index($l,".") < index($r,"."); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | 31 | ▶ | $r =~ s/^/0/ while index($r,".") < index($l,"."); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 219 | 31 | ▶ | $l .= "0" while length($l) < length($r); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | 31 | ▶ | $r .= "0" while length($r) < length($l); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | 31 | my $diffdigit; | |||||||||||||||||||||||||||
| 222 | 31 | ▶ | DIG: for (my $i = 0; $i < length($l); $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | 551 | ▶ | if (substr($l,$i,1) ne substr($r,$i,1)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 224 | 31 | $diffdigit = $i; | |||||||||||||||||||||||||||
| 225 | 31 | last DIG; | |||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | 31 | $ret = substr($l,0,$diffdigit); | |||||||||||||||||||||||||||
| 229 | 31 | my $sl = substr($l,$diffdigit); # significant l | |||||||||||||||||||||||||||
| 230 | 31 | my $sr = substr($r,$diffdigit); | |||||||||||||||||||||||||||
| 231 | 31 | ▶ | if ($ret =~ /\./) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | 30 | $sl .= ".0"; | |||||||||||||||||||||||||||
| 233 | 30 | $sr .= ".0"; | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | 31 | my $srlength = length $sr; | |||||||||||||||||||||||||||
| 236 | 31 | my $srmantissa = $srlength - index($sr,"."); | |||||||||||||||||||||||||||
| 237 | # we want 1+$srlength because if l ends in 99999 and r in 00000, | ||||||||||||||||||||||||||||
| 238 | # we need one digit more | ||||||||||||||||||||||||||||
| 239 | 31 | my $fformat = sprintf "%%0%d.%df", 1+$srlength, $srmantissa; | |||||||||||||||||||||||||||
| 240 | 31 | my $appe = sprintf $fformat, ($sl+$sr)/2; | |||||||||||||||||||||||||||
| 241 | 31 | $appe =~ s/(\d)0+$/$1/; | |||||||||||||||||||||||||||
| 242 | 31 | ▶ | if ($ret =~ /\./) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | 30 | $appe =~ s/\.//; | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | 31 | $ret .= $appe; | |||||||||||||||||||||||||||
| 246 | 31 | CHOP: while () { | |||||||||||||||||||||||||||
| 247 | 477 | my $try = substr($ret,0,length($ret)-1); | |||||||||||||||||||||||||||
| 248 | 477 | ▶ | if (_bigfloatlt($l,$try) && _bigfloatlt($try,$r)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
&_bigfloatlt($l, $try) and &_bigfloatlt($try, $r)
MC/DC50%1/2
&_bigfloatlt($l, $try) and &_bigfloatlt($try, $r)
&_bigfloatlt($l, $try)
&_bigfloatlt($try, $r)
Truth table66%2/3
A and B
A= &_bigfloatlt($l, $try)B= &_bigfloatlt($try, $r)
| |||||||||||||||||||||||||||||
| 249 | 446 | $ret = $try; | |||||||||||||||||||||||||||
| 250 | } else { | ||||||||||||||||||||||||||||
| 251 | 31 | last CHOP; | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | 31 | return $ret; | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | Copyright 2008, 2009 Andreas König. | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 262 | under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | =cut | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 14 | 1; # End of File::Rsync::Mirror::Recentfile | |||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | # Local Variables: | ||||||||||||||||||||||||||||
| 269 | # mode: cperl | ||||||||||||||||||||||||||||
| 270 | # cperl-indent-level: 4 | ||||||||||||||||||||||||||||
| 271 | # End: | ||||||||||||||||||||||||||||