if (isNaN) {
return newNaN(getRuntime());
}
if (isInfinity()) {
return newInfinity(getRuntime(), infinitySign);
}
int n = 0;
if (args.length > 0) {
n = RubyNumeric.fix2int(args[0]);
}
if (value.scale() > n) { // rounding neccessary
return new RubyBigDecimal(getRuntime(),
value.setScale(n, RoundingMode.CEILING));
} else {
return this;
}
if (isNaN) {
return newNaN(getRuntime());
}
if (isInfinity()) {
return newInfinity(getRuntime(), infinitySign);
}
int n = 0;
if (args.length > 0) {
n = RubyNumeric.fix2int(args[0]);
}
if (value.scale() > n) { // rounding neccessary
return new RubyBigDecimal(getRuntime(),
value.setScale(n, RoundingMode.FLOOR));
} else {
return this;
}
Clone fragments detected by clone detection tool
File path: /jruby-1.4.0/src/org/jruby/RubyBigDecimal.java
|
|
File path: /jruby-1.4.0/src/org/jruby/RubyBigDecimal.java
|
Method name: IRubyObject ceil(IRubyObject[])
|
|
Method name: IRubyObject floor(IRubyObject[])
|
Number of AST nodes: 10
|
|
Number of AST nodes: 10
|
|
1 | if (isNaN) {↵ | | 1 | if (isNaN) {↵
|
2 | return newNaN(getRuntime());↵ | | 2 | return newNaN(getRuntime());↵
|
3 | }↵ | | 3 | }↵
|
4 | if (isInfinity()) {↵ | | 4 | if (isInfinity()) {↵
|
5 | return newInfinity(getRuntime(), infinitySign);↵ | | 5 | return newInfinity(getRuntime(), infinitySign);↵
|
6 | }↵ | | 6 | }↵
|
|
7 | int n = 0;↵ | | 7 | int n = 0;↵
|
8 | if (args.length > 0) {↵ | | 8 | if (args.length > 0) {↵
|
9 | n = RubyNumeric.fix2int(args[0]);↵ | | 9 | n = RubyNumeric.fix2int(args[0]);↵
|
10 | }↵ | | 10 | }↵
|
11 | ↵ | | |
|
12 | if (value.scale() > n) { // rounding neccessary↵ | | 11 | if (value.scale() > n) { // rounding neccessary↵
|
13 | return new RubyBigDecimal(getRuntime(),↵ | | 12 | return new RubyBigDecimal(getRuntime(),↵
|
14 | value.setScale(n, RoundingMode.CEILING));↵ | | 13 | value.setScale(n, RoundingMode.FLOOR));↵
|
15 | } else {↵ | | 14 | } else {↵
|
16 | return this;↵ | | 15 | return this;↵
|
17 | } | | 16 | }
|
See real code fragment |
|
See real code fragment |
Summary
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 1 |
Number of non-refactorable cases | 0 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 1.1 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 58 |
-
{Refactorable}
Mapping Summary
Number of mapped statements | 10 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 2.2 |
Clone type | Type 2 |
Mapped Statements
ID |
Statement |
|
ID |
Statement |
1 | if (isNaN) | | 1 | if (isNaN) |
2 | return newNaN(getRuntime()); | | 2 | return newNaN(getRuntime()); |
3 | if (isInfinity()) | | 3 | if (isInfinity()) |
4 | return newInfinity(getRuntime(), infinitySign); | | 4 | return newInfinity(getRuntime(), infinitySign); |
5 | int n = 0; | | 5 | int n = 0; |
6 | if (args.length > 0) | | 6 | if (args.length > 0) |
7 | n = RubyNumeric.fix2int(args[0]); | | 7 | n = RubyNumeric.fix2int(args[0]); |
8 | if (value.scale() > n) | | 8 | if (value.scale() > n) |
9 | return new RubyBigDecimal(getRuntime(), value.setScale(n, RoundingMode.CEILING)); | | 9 | return new RubyBigDecimal(getRuntime(), value.setScale(n, RoundingMode.FLOOR)); |
| | | | |
10 | | | 10 | |
Precondition Violations (0)
Row |
Violation |