line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::LogRand; |
2
|
1
|
|
|
1
|
|
23604
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
3
|
1
|
|
|
1
|
|
29
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
911
|
use POSIX; |
|
1
|
|
|
|
|
6950
|
|
|
1
|
|
|
|
|
7
|
|
5
|
|
|
|
|
|
|
require Exporter; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
8
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
9
|
|
|
|
|
|
|
our @EXPORT = qw( LogRand ); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub LogRand { |
12
|
|
|
|
|
|
|
|
13
|
1002001
|
50
|
|
1002001
|
0
|
5499263
|
shift if $_[0] eq __PACKAGE__; |
14
|
|
|
|
|
|
|
|
15
|
1002001
|
|
|
|
|
1283116
|
my ($floor, $ceil) = @_; |
16
|
|
|
|
|
|
|
|
17
|
1002001
|
50
|
|
|
|
1668604
|
$ceil = $floor if $ceil < $floor; |
18
|
1002001
|
|
|
|
|
929450
|
$ceil = $ceil; # + 1 ; #- $floor; |
19
|
|
|
|
|
|
|
|
20
|
1002001
|
50
|
|
|
|
1600061
|
return $ceil if $floor >= $ceil; |
21
|
1002001
|
|
|
|
|
2203853
|
my $x = $ceil - int( log( rand( $ceil - 1 ) + 1 ) / log( $ceil ) * $ceil ) + $floor; |
22
|
|
|
|
|
|
|
|
23
|
1002001
|
100
|
|
|
|
2311092
|
return $x > $ceil? $ceil : $x; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
1; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
__END__ |