Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Simplify conversion from sign-manitude to two's complement in nqp_big…
…int_shr()
  • Loading branch information
gerdr committed Jul 3, 2013
1 parent c8a6c01 commit bfe5c17
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/vm/parrot/ops/nqp_bigint.ops
Expand Up @@ -374,7 +374,6 @@ inline op nqp_bigint_div_num(out NUM, invar PMC, invar PMC) :base_core {
inline op nqp_bigint_shr(out PMC, invar PMC, in INT, invar PMC) :base_core {
mp_int *a = get_bigint(interp, $2);
mp_int *b;
mp_int c;
$1 = REPR($4)->allocate(interp, STABLE($4));
REPR($1)->initialize(interp, STABLE($1), OBJECT_BODY($1));
b = get_bigint(interp, $1);
Expand All @@ -383,15 +382,9 @@ inline op nqp_bigint_shr(out PMC, invar PMC, in INT, invar PMC) :base_core {
mp_mul_2d(a, -1 * $3, b);
}
else if (MP_NEG == SIGN(a)) {
mp_abs(a, b);
mp_init(&c);
mp_div_2d(b, $3, b, &c);
if ( USED(&c) & 1 ) {
mp_zero(&c);
mp_set_int(&c, 1);
mp_add(b, &c, b);
}
mp_neg(b, b);
mp_add_d(a, 1, b);
mp_div_2d(b, $3, b, NULL);
mp_sub_d(b, 1, b);
}
else {
mp_div_2d(a, $3, b, NULL);
Expand Down

0 comments on commit bfe5c17

Please sign in to comment.