Skip to content

Commit 68c2020

Browse files
committed
Use new conversion functions in BigDecimal_DoDivmod
1 parent a109d09 commit 68c2020

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

ext/bigdecimal/bigdecimal.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,18 +1425,25 @@ BigDecimal_DoDivmod(VALUE self, VALUE r, Real **div, Real **mod)
14251425
Real *a, *b;
14261426
size_t mx;
14271427

1428-
GUARD_OBJ(a, GetVpValue(self, 1));
1428+
TypedData_Get_Struct(self, Real, &BigDecimal_data_type, a);
1429+
SAVE(a);
1430+
1431+
VALUE rr = Qnil;
14291432
if (RB_TYPE_P(r, T_FLOAT)) {
1430-
b = GetVpValueWithPrec(r, 0, 1);
1433+
rr = rb_float_convert_to_BigDecimal(r, 0, true);
14311434
}
14321435
else if (RB_TYPE_P(r, T_RATIONAL)) {
1433-
b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1);
1436+
rr = rb_rational_convert_to_BigDecimal(r, a->Prec*BASE_FIG, true);
14341437
}
14351438
else {
1436-
b = GetVpValue(r, 0);
1439+
rr = rb_convert_to_BigDecimal(r, 0, false);
14371440
}
14381441

1439-
if (!b) return Qfalse;
1442+
if (!is_kind_of_BigDecimal(rr)) {
1443+
return Qfalse;
1444+
}
1445+
1446+
TypedData_Get_Struct(rr, Real, &BigDecimal_data_type, b);
14401447
SAVE(b);
14411448

14421449
if (VpIsNaN(a) || VpIsNaN(b)) goto NaN;

0 commit comments

Comments
 (0)