Skip to content

Commit

Permalink
Implement div_In.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Apr 8, 2013
1 parent fab1b73 commit ef13c49
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/QAST/JASTCompiler.nqp
Expand Up @@ -1552,6 +1552,7 @@ QAST::OperationsJAST.map_classlib_core_op('mul_I', $TYPE_OPS, 'mul_I', [$RT_OBJ,
QAST::OperationsJAST.map_jvm_core_op('mul_n', 'dmul', [$RT_NUM, $RT_NUM], $RT_NUM);
QAST::OperationsJAST.map_jvm_core_op('div_i', 'ldiv', [$RT_INT, $RT_INT], $RT_INT);
QAST::OperationsJAST.map_classlib_core_op('div_I', $TYPE_OPS, 'div_I', [$RT_OBJ, $RT_OBJ, $RT_OBJ], $RT_OBJ, :tc);
QAST::OperationsJAST.map_classlib_core_op('div_In', $TYPE_OPS, 'div_In', [$RT_OBJ, $RT_OBJ], $RT_NUM, :tc);
QAST::OperationsJAST.map_jvm_core_op('div_n', 'ddiv', [$RT_NUM, $RT_NUM], $RT_NUM);
QAST::OperationsJAST.map_jvm_core_op('mod_i', 'lrem', [$RT_INT, $RT_INT], $RT_INT);
QAST::OperationsJAST.map_classlib_core_op('mod_I', $TYPE_OPS, 'mod_I', [$RT_OBJ, $RT_OBJ, $RT_OBJ], $RT_OBJ, :tc);
Expand Down
4 changes: 4 additions & 0 deletions src/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -3228,6 +3228,10 @@ public static SixModelObject div_I(SixModelObject a, SixModelObject b, SixModelO
return makeBI(tc, type, getBI(tc, a).divide(getBI(tc, b)));
}

public static double div_In(SixModelObject a, SixModelObject b, ThreadContext tc) {
return new BigDecimal(getBI(tc, a)).divide(new BigDecimal(getBI(tc, b))).doubleValue();
}

public static SixModelObject mod_I(SixModelObject a, SixModelObject b, SixModelObject type, ThreadContext tc) {
return makeBI(tc, type, getBI(tc, a).mod(getBI(tc, b)));
}
Expand Down

0 comments on commit ef13c49

Please sign in to comment.