method
div
v1_9_3_125 -
Show latest stable
-
0 notes -
Class: BigDecimal
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378 (0)
- 1_9_2_180 (0)
- 1_9_3_125 (0)
- 1_9_3_392 (0)
- 2_1_10 (0)
- 2_2_9 (0)
- 2_4_6 (38)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
div(p1, p2 = v2)
public
Hide source
static VALUE BigDecimal_div2(int argc, VALUE *argv, VALUE self) { ENTER(5); VALUE b,n; int na = rb_scan_args(argc,argv,"11",&b,&n); if(na==1) { /* div in Float sense */ Real *div=NULL; Real *mod; if(BigDecimal_DoDivmod(self,b,&div,&mod)) { return BigDecimal_to_i(ToValue(div)); } return DoSomeOne(self,b,rb_intern("div")); } else { /* div in BigDecimal sense */ SIGNED_VALUE ix = GetPositiveInt(n); if (ix == 0) return BigDecimal_div(self, b); else { Real *res=NULL; Real *av=NULL, *bv=NULL, *cv=NULL; size_t mx = (ix+VpBaseFig()*2); size_t pl = VpSetPrecLimit(0); GUARD_OBJ(cv,VpCreateRbObject(mx,"0")); GUARD_OBJ(av,GetVpValue(self,1)); GUARD_OBJ(bv,GetVpValue(b,1)); mx = av->Prec + bv->Prec + 2; if(mx <= cv->MaxPrec) mx = cv->MaxPrec+1; GUARD_OBJ(res,VpCreateRbObject((mx * 2 + 2)*VpBaseFig(), "#0")); VpDivd(cv,res,av,bv); VpSetPrecLimit(pl); VpLeftRound(cv,VpGetRoundMode(),ix); return ToValue(cv); } } }