line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Float::Truncate; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
72924
|
use strict; |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
30
|
use 5.008_005; |
|
1
|
|
|
|
|
5
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
6
|
1
|
|
|
1
|
|
10
|
use vars qw/@ISA @EXPORT @EXPORT_OK/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
337
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
9
|
|
|
|
|
|
|
@EXPORT = @EXPORT_OK = qw/truncate truncate_force/; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub truncate { |
12
|
3
|
|
|
3
|
0
|
98
|
my ( $number, $length ) = @_; |
13
|
3
|
100
|
|
|
|
18
|
return $number unless defined $length; |
14
|
2
|
|
|
|
|
23
|
return sprintf "%.${length}f", $number; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub truncate_force { |
18
|
3
|
|
|
3
|
0
|
8
|
my ( $number, $length ) = @_; |
19
|
3
|
100
|
|
|
|
12
|
return $number unless defined $length; |
20
|
|
|
|
|
|
|
|
21
|
2
|
|
|
|
|
5
|
$length = 10**$length; |
22
|
2
|
|
|
|
|
11
|
return int( $number * $length ) / $length; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |
26
|
|
|
|
|
|
|
__END__ |