[前][次][番号順一覧][スレッド一覧]

ruby-changes:52519

From: hsbt <ko1@a...>
Date: Thu, 13 Sep 2018 17:23:31 +0900 (JST)
Subject: [ruby-changes:52519] hsbt:r64729: Move unlabeled-1.39.2 branch to tags.

hsbt	2018-09-13 16:05:13 +0900 (Thu, 13 Sep 2018)

  New Revision: 64729

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64729

  Log:
    Move unlabeled-1.39.2 branch to tags.

  Added directories:
    tags/unlabeled-1.39.2/
  Removed directories:
    branches/unlabeled-1.39.2/
Index: unlabeled-1.39.2/ext/bigdecimal/bigdecimal.c
===================================================================
--- unlabeled-1.39.2/ext/bigdecimal/bigdecimal.c	(revision 64728)
+++ unlabeled-1.39.2/ext/bigdecimal/bigdecimal.c	(nonexistent)
@@ -1,4058 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/unlabeled-1.39.2/ext/bigdecimal/bigdecimal.c#L0
-/*
- *
- * Ruby BigDecimal(Variable decimal precision) extension library.
- *
- * Copyright(C) 2002 by Shigeo Kobayashi(shigeo@t...)
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file
- * of this BigDecimal distribution.
- *
- *  NOTE: Change log in this source removed to reduce source code size. 
- *        See rev. 1.25 if needed.
- *
- */
-
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <float.h>
-#include <math.h>
-#include "ruby.h"
-#include "math.h"
-#include "version.h"
- 
-/* #define ENABLE_NUMERIC_STRING */
-
-VALUE rb_cBigDecimal;
-
-#include "bigdecimal.h"
-
-/* MACRO's to guard objects from GC by keeping them in stack */
-#define ENTER(n) volatile VALUE vStack[n];int iStack=0
-#define PUSH(x)  vStack[iStack++] = (unsigned long)(x);
-#define SAVE(p)  PUSH(p->obj);
-#define GUARD_OBJ(p,y) {p=y;SAVE(p);}
-
-/*
- * ================== Ruby Interface part ==========================
- */
-#define DoSomeOne(x,y) rb_num_coerce_bin(x,y)
-
-/*
- *  **** BigDecimal version ****
- */
-static VALUE
-BigDecimal_version(VALUE self)
-{
-    /*
-     * 1.0.0: Ruby 1.8.0
-     * 1.0.1: Ruby 1.8.1
-    */
-    return rb_str_new2("1.0.1");
-}
-
-/*
- *   VP routines used in BigDecimal part 
- */
-static unsigned short VpGetException(void);
-static void  VpSetException(unsigned short f);
-static void  VpInternalRound(Real *c,int ixDigit,U_LONG vPrev,U_LONG v);
-static int   VpLimitRound(Real *c,U_LONG ixDigit);
-
-/*
- *  **** BigDecimal part ****
- */
-
-static void
-BigDecimal_delete(Real *pv)
-{
-    VpFree(pv);
-}
-
-static VALUE
-ToValue(Real *p)
-{
-    if(VpIsNaN(p)) {
-        VpException(VP_EXCEPTION_NaN,"Computation results to 'NaN'(Not a Number)",0);
-    } else if(VpIsPosInf(p)) {
-        VpException(VP_EXCEPTION_INFINITY,"Computation results to 'Infinity'",0);
-    } else if(VpIsNegInf(p)) {
-        VpException(VP_EXCEPTION_INFINITY,"Computation results to '-Infinity'",0);
-    }
-    return p->obj;
-}
-
-static Real *
-GetVpValue(VALUE v, int must)
-{
-    Real *pv;
-    VALUE bg;
-    char szD[128];
-
-    switch(TYPE(v))
-    {
-    case T_DATA:
-        if(RDATA(v)->dfree ==(void *) BigDecimal_delete) {
-            Data_Get_Struct(v, Real, pv);
-            return pv;
-        } else {
-            goto SomeOneMayDoIt;
-        }
-        break;
-    case T_FIXNUM:
-        sprintf(szD, "%ld", FIX2LONG(v));
-        return VpCreateRbObject(VpBaseFig() * 2 + 1, szD);
-
-#ifdef ENABLE_NUMERIC_STRING
-    case T_STRING:
-        SafeStringValue(v);
-        return VpCreateRbObject(strlen(RSTRING(v)->ptr) + VpBaseFig() + 1,
-                                RSTRING(v)->ptr);
-#endif /* ENABLE_NUMERIC_STRING */
-
-    case T_BIGNUM:
-        bg = rb_big2str(v, 10);
-        return VpCreateRbObject(strlen(RSTRING(bg)->ptr) + VpBaseFig() + 1,
-                                RSTRING(bg)->ptr);
-    default:
-        goto SomeOneMayDoIt;
-    }
-
-SomeOneMayDoIt:
-    if(must) {
-        rb_raise(rb_eTypeError, "%s can't be coerced into BigDecimal",
-                    rb_special_const_p(v)?
-                    RSTRING(rb_inspect(v))->ptr:
-                    rb_obj_classname(v)
-                );
-    }
-    return NULL; /* NULL means to coerce */
-}
-
-static VALUE
-BigDecimal_double_fig(VALUE self)
-{
-    return INT2FIX(VpDblFig());
-}
-
-static VALUE
-BigDecimal_prec(VALUE self)
-{
-    ENTER(1);
-    Real *p;
-    VALUE obj;
-
-    GUARD_OBJ(p,GetVpValue(self,1));
-    obj = rb_assoc_new(INT2NUM(p->Prec*VpBaseFig()),
-		       INT2NUM(p->MaxPrec*VpBaseFig()));
-    return obj;
-}
-
-static VALUE
-BigDecimal_hash(VALUE self)
-{
-    ENTER(1);
-    Real *p;
-    U_LONG hash,i;
-
-    GUARD_OBJ(p,GetVpValue(self,1));
-    hash = (U_LONG)p->sign;
-    /* hash!=2: the case for 0(1),NaN(0) or +-Infinity(3) is sign itself */
-    if(hash==2) {
-        for(i = 0; i < p->Prec;i++) {
-            hash = 31 * hash + p->frac[i];
-            hash ^= p->frac[i];
-        }
-        hash += p->exponent;
-    }
-    return INT2FIX(hash);
-}
-
-static VALUE
-BigDecimal_dump(int argc, VALUE *argv, VALUE self)
-{
-    ENTER(5);
-    char sz[50];
-    Real *vp;
-    char *psz;
-    VALUE dummy;
-    rb_scan_args(argc, argv, "01", &dummy);
-    GUARD_OBJ(vp,GetVpValue(self,1));
-    sprintf(sz,"%lu:",VpMaxPrec(vp)*VpBaseFig());
-    psz = ALLOCA_N(char,(unsigned int)VpNumOfChars(vp,"E")+strlen(sz));
-    sprintf(psz,"%s",sz);
-    VpToString(vp, psz+strlen(psz), 0, 0);
-    return rb_str_new2(psz);
-}
-
-static VALUE
-BigDecimal_load(VALUE self, VALUE str)
-{
-    ENTER(2);
-    Real *pv;
-    unsigned char *pch;
-    unsigned char ch;
-    unsigned long m=0;
-
-    SafeStringValue(str);
-    pch = RSTRING(str)->ptr;
-    /* First get max prec */
-    while((*pch)!=(unsigned char)'\0' && (ch=*pch++)!=(unsigned char)':') {
-        if(!ISDIGIT(ch)) {
-            rb_raise(rb_eTypeError, "Load failed: invalid character in the marshaled string");
-        }
-        m = m*10 + (unsigned long)(ch-'0');
-    }
-    if(m>VpBaseFig()) m -= VpBaseFig();
-    GUARD_OBJ(pv,VpNewRbClass(m,pch,self));
-    m /= VpBaseFig();
-    if(m && pv->MaxPrec>m) pv->MaxPrec = m+1;
-    return ToValue(pv);
-}
-
-static VALUE
-BigDecimal_mode(int argc, VALUE *argv, VALUE self)
-{
-    VALUE which;
-    VALUE val;
-    unsigned long f,fo;
- 
-    if(rb_scan_args(argc,argv,"11",&which,&val)==1) val = Qnil;
-
-    Check_Type(which, T_FIXNUM);
-    f = (unsigned long)FIX2INT(which);
-
-    if(f&VP_EXCEPTION_ALL) {
-        /* Exception mode setting */
-        fo = VpGetException();
-        if(val==Qnil) return INT2FIX(fo);
-        if(val!=Qfalse && val!=Qtrue) {
-            rb_raise(rb_eTypeError, "The second argument must be true or false.");
-            return Qnil; /* Not reached */
-        }
-        if(f&VP_EXCEPTION_INFINITY) {
-            VpSetException((unsigned short)((val==Qtrue)?(fo|VP_EXCEPTION_INFINITY):
-                           (fo&(~VP_EXCEPTION_INFINITY))));
-        }
-        if(f&VP_EXCEPTION_NaN) {
-            VpSetException((unsigned short)((val==Qtrue)?(fo|VP_EXCEPTION_NaN):
-                           (fo&(~VP_EXCEPTION_NaN))));
-        }
-        fo = VpGetException();
-        return INT2FIX(fo);
-    }
-    if(VP_ROUND_MODE==f) {
-        /* Rounding mode setting */
-        fo = VpGetRoundMode();
-        if(val==Qnil) return INT2FIX(fo);
-        Check_Type(val, T_FIXNUM);
-        if(!VpIsRoundMode(FIX2INT(val))) {
-            rb_raise(rb_eTypeError, "Invalid rounding mode.");
-            return Qnil;
-        }
-        fo = VpSetRoundMode((unsigned long)FIX2INT(val));
-        return INT2FIX(fo);
-    }
-    rb_raise(rb_eTypeError, "The first argument for BigDecimal#mode is invalid.");
-    return Qnil;
-}
-
-static U_LONG
-GetAddSubPrec(Real *a, Real *b)
-{
-    U_LONG mxs;
-    U_LONG mx = a->Prec;
-    S_INT d;
-
-    if(!VpIsDef(a) || !VpIsDef(b)) return (-1L);
-    if(mx < b->Prec) mx = b->Prec;
-    if(a->exponent!=b->exponent) {
-        mxs = mx;
-        d = a->exponent - b->exponent;
-        if(d<0) d = -d;
-        mx = mx+(U_LONG)d;
-        if(mx<mxs) {
-            return VpException(VP_EXCEPTION_INFINITY,"Exponent overflow",0);
-        }
-    }
-    return mx;
-}
-
-static S_INT
-GetPositiveInt(VALUE v)
-{
-    S_INT n;
-    Check_Type(v, T_FIXNUM);
-    n = FIX2INT(v);
-    if(n < 0) {
-        rb_raise(rb_eArgError, "argument must be positive");
-    }
-    return n;
-}
-
-VP_EXPORT Real *
-VpNewRbClass(U_LONG mx, char *str, VALUE klass)
-{
-    Real *pv = VpAlloc(mx,str);
-    pv->obj = (VALUE)Data_Wrap_Struct(klass, 0, BigDecimal_delete, pv);
-    return pv;
-}
-
-VP_EXPORT Real *
-VpCreateRbObject(U_LONG mx, char *str)
-{
-    Real *pv = VpAlloc(mx,str);
-    pv->obj = (VALUE)Data_Wrap_Struct(rb_cBigDecimal, 0, BigDecimal_delete, pv);
-    return pv;
-}
-
-
-static VALUE
-BigDecimal_IsNaN(VALUE self)
-{
-    Real *p = GetVpValue(self,1);
-    if(VpIsNaN(p))  return Qtrue;
-    return Qfalse;
-}
-
-static VALUE
-BigDecimal_IsInfinite(VALUE self)
-{
-    Real *p = GetVpValue(self,1);
-    if(VpIsPosInf(p)) return INT2FIX(1);
-    if(VpIsNegInf(p)) return INT2FIX(-1);
-    return Qnil;
-}
-
-static VALUE
-BigDecimal_IsFinite(VALUE self)
-{
-    Real *p = GetVpValue(self,1);
-    if(VpIsNaN(p)) return Qfalse;
-    if(VpIsInf(p)) return Qfalse;
-    return Qtrue;
-}
-
-static VALUE
-BigDecimal_to_i(VALUE self)
-{
-    ENTER(5);
-    int e,n,i,nf;
-    U_LONG v,b,j;
-    char *psz,*pch;
-    Real *p;
-
-    GUARD_OBJ(p,GetVpValue(self,1));
-
-    /* Infinity or NaN not converted. */
-    if(VpIsNaN(p)) {
-       VpException(VP_EXCEPTION_NaN,"Computation results to 'NaN'(Not a Number)",0);
-       return Qnil;
-    } else if(VpIsPosInf(p)) {
-       VpException(VP_EXCEPTION_INFINITY,"Computation results to 'Infinity'",0);
-       return Qnil;
-    } else if(VpIsNegInf(p)) {
-       VpException(VP_EXCEPTION_INFINITY,"Computation results to '-Infinity'",0);
-       return Qnil;
-    }
-
-    e = VpExponent10(p);
-    if(e<=0) return INT2FIX(0);
-    nf = VpBaseFig();
-    if(e<=nf) {
-        e = VpGetSign(p)*p->frac[0];
-        return INT2FIX(e);
-    }
-    psz = ALLOCA_N(char,(unsigned int)(e+nf+2));
-
-    n = (e+nf-1)/nf;
-    pch = psz;
-    if(VpGetSign(p)<0) *pch++ = '-';
-    for(i=0;i<n;++i) {
-        b = VpBaseVal()/10;
-        if(i>=(int)p->Prec) {
-            while(b) {
-                *pch++ = '0';
-                b /= 10;
-            }
-            continue;
-        }
-        v = p->frac[i];
-        while(b) {
-            j = v/b;
-            *pch++ = (char)(j + '0');
-            v -= j*b;
-            b /= 10;
-        }
-    }
-    *pch++ = 0;
-    return rb_cstr2inum(psz,10);
-}
-
-static VALUE
-BigDecimal_induced_from(VALUE self, VALUE x)
-{
-    Real *p = GetVpValue(x,1);
-    return p->obj;
-}
-
-static VALUE
-BigDecimal_to_f(VALUE self)
-{
-    ENTER(1);
-    Real *p;
-    double d, d2;
-    S_LONG e;
-
-    GUARD_OBJ(p,GetVpValue(self,1));
-    if(VpVtoD(&d, &e, p)!=1) return rb_float_new(d);
-    errno = 0;
-    d2 = pow(10.0,(double)e);
-    if((errno == ERANGE && e>0) || (d2>1.0 && (fabs(d) > (DBL_MAX / d2)))) {
-       VpException(VP_EXCEPTION_OVERFLOW,"BigDecimal to Float conversion.",0);
-       if(d>0.0) return rb_float_new(DBL_MAX);
-       else      return rb_float_new(-DBL_MAX);
-    }
-    return rb_float_new(d*d2);
-}
-
-static VALUE
-BigDecimal_coerce(VALUE self, VALUE other)
-{
-    ENTER(2);
-    VALUE obj;
-    Real *b;
-    if(TYPE(other) == T_FLOAT) {
-       obj = rb_assoc_new(other, BigDecimal_to_f(self));
-    } else {
-       GUARD_OBJ(b,GetVpValue(other,1));
-       obj = rb_assoc_new(b->obj, self);
-    }
-    return obj;
-}
-
-static VALUE
-BigDecimal_uplus(VALUE self)
-{
-    return self;
-}
-
-static VALUE
-BigDecimal_add(VALUE self, VALUE r)
-{
-    ENTER(5);
-    Real *c, *a, *b;
-    U_LONG mx;
-    GUARD_OBJ(a,GetVpValue(self,1));
-    b = GetVpValue(r,0);
-    if(!b) return DoSomeOne(self,r);
-    SAVE(b);
-    if(VpIsNaN(b)) return b->obj;
-    if(VpIsNaN(a)) return a->obj;
-    mx = GetAddSubPrec(a,b);
-    if(mx==(-1L)) {
-        GUARD_OBJ(c,VpCreateRbObject(VpBaseFig() + 1, "0"));
-        VpAddSub(c, a, b, 1);
-    } else {
-        GUARD_OBJ(c,VpCreateRbObject(mx *(VpBaseFig() + 1), "0"));
-        if(!mx) {
-            VpSetInf(c,VpGetSign(a));
-        } else {
-            VpAddSub(c, a, b, 1);
-        }
-    }
-    return ToValue(c);
-}
-
-static VALUE
-BigDecimal_sub(VALUE self, VALUE r)
-{
-    ENTER(5);
-    Real *c, *a, *b;
-    U_LONG mx;
-
-    GUARD_OBJ(a,GetVpValue(self,1));
-    b = GetVpValue(r,0);
-    if(!b) return DoSomeOne(self,r);
-    SAVE(b);
-
-    if(VpIsNaN(b)) return b->obj;
-    if(VpIsNaN(a)) return a->obj;
-
-    mx = GetAddSubPrec(a,b);
-    if(mx==(-1L)) {
-        GUARD_OBJ(c,VpCreateRbObject(VpBaseFig() + 1, "0"));
-        VpAddSub(c, a, b, -1);
-    } else {
-        GUARD_OBJ(c,VpCreateRbObject(mx *(VpBaseFig() + 1), "0"));
-        if(!mx) {
-            VpSetInf(c,VpGetSign(a));
-        } else {
-            VpAddSub(c, a, b, -1);
-        }
-    }
-    return ToValue(c);
-}
-
-static VALUE
-BigDecimalCmp(VALUE self, VALUE r,char op)
-{
-    ENTER(5);
-    S_INT e;
-    Real *a, *b;
-    GUARD_OBJ(a,GetVpValue(self,1));
-    b = GetVpValue(r,0);
-    if(!b) return rb_num_coerce_cmp(self,r);
-    SAVE(b);
-    e = VpComp(a, b);
-    if(e==999) return Qnil;
-    switch(op)
-    {
-    case '*': return   INT2FIX(e); /* any op */
-    case '=': if(e==0) return Qtrue ; return Qfalse;
-    case '!': if(e!=0) return Qtrue ; return Qfalse;
-    case 'G': if(e>=0) return Qtrue ; return Qfalse;
-    case '>': if(e> 0) return Qtrue ; return Qfalse;
-    case 'L': if(e<=0) return Qtrue ; return Qfalse;
-    case '<': if(e< 0) return Qtrue ; return Qfalse;
-    }
-    rb_bug("Undefined operation in BigDecimalCmp()");
-}
-
-static VALUE
-BigDecimal_zero(VALUE self)
-{
-    Real *a = GetVpValue(self,1);
-    return VpIsZero(a) ? Qtrue : Qfalse;
-}
-
-static VALUE
-BigDecimal_nonzero(VALUE self)
-{
-    Real *a = GetVpValue(self,1);
-    return VpIsZero(a) ? Qnil : self;
-}
-
-static VALUE
-BigDecimal_comp(VALUE self, VALUE r)
-{
-    return BigDecimalCmp(self, r, '*');
-}
-
-static VALUE
-BigDecimal_eq(VALUE self, VALUE r)
-{
-    return BigDecimalCmp(self, r, '=');
-}
-
-static VALUE
-BigDecimal_ne(VALUE self, VALUE r)
-{
-    return BigDecimalCmp(self, r, '!');
-}
-
-static VALUE
-BigDecimal_lt(VALUE self, VALUE r)
-{
-    return BigDecimalCmp(self, r, '<');
-}
-
-static VALUE
-BigDecimal_le(VALUE self, VALUE r)
-{
-    return BigDecimalCmp(self, r, 'L');
-}
-
-static VALUE
-BigDecimal_gt(VALUE self, VALUE r)
-{
-    return BigDecimalCmp(self, r, '>');
-}
-
-static VALUE
-BigDecimal_ge(VALUE self, VALUE r)
-{
-    return BigDecimalCmp(self, r, 'G');
-}
-
-static VALUE
-BigDecimal_neg(VALUE self, VALUE r)
-{
-    ENTER(5);
-    Real *c, *a;
-    GUARD_OBJ(a,GetVpValue(self,1));
-    GUARD_OBJ(c,VpCreateRbObject(a->Prec *(VpBaseFig() + 1), "0"));
-    VpAsgn(c, a, -1);
-    return ToValue(c);
-}
-
-static VALUE
-BigDecimal_mult(VALUE self, VALUE r)
-{
-    ENTER(5);
-    Real *c, *a, *b;
-    U_LONG mx;
-
-    GUARD_OBJ(a,GetVpValue(self,1));
-    b = GetVpValue(r,0);
-    if(!b) return DoSomeOne(self,r);
-    SAVE(b);
-
-    mx = a->Prec + b->Prec;
-    GUARD_OBJ(c,VpCreateRbObject(mx *(VpBaseFig() + 1), "0"));
-    VpMult(c, a, b);
-    return ToValue(c);
-}
-
-static VALUE
-BigDecimal_divide(Real **c, Real **res, Real **div, VALUE self, VALUE r)
-/* For c = self.div(r): with round operation */
-{
-    ENTER(5);
-    Real *a, *b;
-    U_LONG mx;
-
-    GUARD_OBJ(a,GetVpValue(self,1));
-    b = GetVpValue(r,0);
-    if(!b) return DoSomeOne(self,r);
-    SAVE(b);
-    *div = b;
-    mx =(a->MaxPrec + b->MaxPrec + 1) * VpBaseFig();
-    GUARD_OBJ((*c),VpCreateRbObject(mx, "#0"));
-    GUARD_OBJ((*res),VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
-    VpDivd(*c, *res, a, b);
-    return (VALUE)0;
-}
-
-static VALUE
-BigDecimal_div(VALUE self, VALUE r)
-/* For c = self/r: with round operation */
-{
-    ENTER(5);
-    Real *c=NULL, *res=NULL, *div = NULL;
-    r = BigDecimal_divide(&c, &res, &div, self, r);
-    if(r!=(VALUE)0) return r; /* coerced by other */
-    SAVE(c);SAVE(res);SAVE(div);
-    /* a/b = c + r/b */
-    /* c xxxxx
-       r 00000yyyyy  ==> (y/b)*BASE >= HALF_BASE
-     */
-    /* Round */
-    if(VpHasVal(div)) { /* frac[0] must be zero for NaN,INF,Zero */
-       VpInternalRound(c,0,c->frac[c->Prec-1],(VpBaseVal()*res->frac[0])/div->frac[0]);
-    }
-    return ToValue(c);
-}
-
-/*
- * %: mod = a%b = a - (a.to_f/b).floor * b
- * div = (a.to_f/b).floor
- */
-static VALUE
-BigDecimal_DoDivmod(VALUE self, VALUE r, Real **div, Real **mod)
-{
-    ENTER(8);
-    Real *c=NULL, *d=NULL, *res=NULL;
-    Real *a, *b;
-    U_LONG mx;
-
-    GUARD_OBJ(a,GetVpValue(self,1));
-    b = GetVpValue(r,0);
-    if(!b) return DoSomeOne(self,r);
-    SAVE(b);
-
-    if(VpIsNaN(a) || VpIsNaN(b)) goto NaN;
-    if(VpIsInf(a) || VpIsInf(b)) goto NaN;
-    if(VpIsZero(b))              goto NaN;
-    if(VpIsZero(a)) {
-       GUARD_OBJ(c,VpCreateRbObject(1, "0"));
-       GUARD_OBJ(d,VpCreateRbObject(1, "0"));
-       *div = d;
-       *mod = c;
-       return (VALUE)0;
-    }
-
-    mx = a->Prec;
-    if(mx<b->Prec) mx = b->Prec;
-    mx =(mx + 1) * VpBaseFig();
-    GUARD_OBJ(c,VpCreateRbObject(mx, "0"));
-    GUARD_OBJ(res,VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
-    VpDivd(c, res, a, b);
-    mx = c->Prec *(VpBaseFig() + 1);
-    GUARD_OBJ(d,VpCreateRbObject(mx, "0"));
-    VpActiveRound(d,c,VP_ROUND_DOWN,0);
-    VpMult(res,d,b);
-    VpAddSub(c,a,res,-1);
-    if(!VpIsZero(c) && (VpGetSign(a)*VpGetSign(b)<0)) {
-        VpAddSub(res,d,VpOne(),-1);
-        VpAddSub(d  ,c,b,       1);
-        *div = res;
-        *mod = d;
-    } else {
-        *div = d;
-        *mod = c;
-    }
-    return (VALUE)0;
-
-NaN:
-    GUARD_OBJ(c,VpCreateRbObject(1, "NaN"));
-    GUARD_OBJ(d,VpCreateRbObject(1, "NaN"));
-    *div = d;
-    *mod = c;
-    return (VALUE)0;
-}
-
-static VALUE
-BigDecimal_mod(VALUE self, VALUE r) /* %: a%b = a - (a.to_f/b).floor * b */
-{
-    ENTER(3);
-    VALUE obj;
-    Real *div=NULL, *mod=NULL;
-
-    obj = BigDecimal_DoDivmod(self,r,&div,&mod);
-    if(obj!=(VALUE)0) return obj;
-    SAVE(div);SAVE(mod);
-    return ToValue(mod);
-}
-
-static VALUE
-BigDecimal_divremain(VALUE self, VALUE r, Real **dv, Real **rv)
-{
-    ENTER(10);
-    U_LONG mx;
-    Real *a=NULL, *b=NULL, *c=NULL, *res=NULL, *d=NULL, *rr=NULL, *ff=NULL;
-    Real *f=NULL;
-
-    GUARD_OBJ(a,GetVpValue(self,1));
-    b = GetVpValue(r,0);
-    if(!b) return DoSomeOne(self,r);
-    SAVE(b);
-
-    mx  =(a->MaxPrec + b->MaxPrec) *VpBaseFig();
-    GUARD_OBJ(c  ,VpCreateRbObject(mx, "0"));
-    GUARD_OBJ(res,VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
-    GUARD_OBJ(rr ,VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
-    GUARD_OBJ(ff ,VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1), "#0"));
-
-    VpDivd(c, res, a, b);
-
-    mx = c->Prec *(VpBaseFig() + 1);
-
-    GUARD_OBJ(d,VpCreateRbObject(mx, "0"));
-    GUARD_OBJ(f,VpCreateRbObject(mx, "0"));
-
-    VpActiveRound(d,c,VP_ROUND_DOWN,0); /* 0: round off */
-
-    VpFrac(f, c);
-    VpMult(rr,f,b);
-    VpAddSub(ff,res,rr,1);
-
-    *dv = d;
-    *rv = ff;
-    return (VALUE)0;
-}
-
-static VALUE
-BigDecimal_remainder(VALUE self, VALUE r) /* remainder */
-{
-    VALUE  f;
-    Real  *d,*rv;
-    f = BigDecimal_divremain(self,r,&d,&rv);
-    if(f!=(VALUE)0) return f;
-    return ToValue(rv);
-}
-
-static VALUE
-BigDecimal_divmod(VALUE self, VALUE r)
-{
-    ENTER(5);
-    VALUE obj;
-    Real *div=NULL, *mod=NULL;
-
-    obj = BigDecimal_DoDivmod(self,r,&div,&mod);
-    if(obj!=(VALUE)0) return obj;
-    SAVE(div);SAVE(mod);
-    obj = rb_assoc_new(ToValue(div), ToValue(mod));
-    return obj;
-}
-
-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 */
-       VALUE obj;
-       Real *div=NULL;
-       Real *mod;
-       obj = BigDecimal_DoDivmod(self,b,&div,&mod);
-       if(obj!=(VALUE)0) return obj;
-       return ToValue(div);
-    } else {    /* div in BigDecimal sense */
-       U_LONG ix = (U_LONG)GetPositiveInt(n);
-       if(ix==0) return BigDecimal_div(sel (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]