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
        }
Summary
Number of common nesting structure subtrees1
Number of refactorable cases1
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)1.1
Clones locationClones are declared in the same class
Number of node comparisons58
  1. {Refactorable}
    Mapping Summary
    Number of mapped statements10
    Number of unmapped statements in the first code fragment0
    Number of unmapped statements in the second code fragment0
    Time elapsed for statement mapping (ms)2.2
    Clone typeType 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.CEILING));
    9
    return new RubyBigDecimal(getRuntime(), value.setScale(n, RoundingMode.FLOOR));
    Differences
    Expression1Expression2Difference
    CEILINGFLOORVARIABLE_NAME_MISMATCH
    9
    return new RubyBigDecimal(getRuntime(), value.setScale(n, RoundingMode.FLOOR));
    else
    else
    10
    return this;
    10
    return this;
    Precondition Violations (0)
    Row Violation