The R Project SVN R

Rev

Rev 33297 | Rev 35758 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 33297 Rev 34301
Line 170... Line 170...
170
    R_NaReal = R_ValueOfNA();
170
    R_NaReal = R_ValueOfNA();
171
    R_PosInf = 1.0/R_Zero_Hack;
171
    R_PosInf = 1.0/R_Zero_Hack;
172
    R_NegInf = -1.0/R_Zero_Hack;
172
    R_NegInf = -1.0/R_Zero_Hack;
173
}
173
}
174
 
174
 
-
 
175
/* Keep these two in step */
175
static double myfmod(double x1, double x2)
176
static double myfmod(double x1, double x2)
176
{
177
{
177
    double q = x1 / x2, tmp;
178
    double q = x1 / x2, tmp;
178
 
179
 
179
    if (x2 == 0.0) return R_NaN;
180
    if (x2 == 0.0) return R_NaN;
Line 182... Line 183...
182
	warning(_("probable complete loss of accuracy in modulus"));
183
	warning(_("probable complete loss of accuracy in modulus"));
183
    q = floor(tmp/x2);
184
    q = floor(tmp/x2);
184
    return tmp - q * x2;
185
    return tmp - q * x2;
185
}
186
}
186
 
187
 
-
 
188
static double myfloor(double x1, double x2)
-
 
189
{
-
 
190
    double q = x1 / x2, tmp;
-
 
191
 
-
 
192
    if (x2 == 0.0) return q;
-
 
193
    tmp = x1 - floor(q) * x2;
-
 
194
    return floor(q) + floor(tmp/x2);
-
 
195
}
-
 
196
 
187
 
197
 
188
#ifdef HAVE_WORKING_LOG
198
#ifdef HAVE_WORKING_LOG
189
# define R_log	log
199
# define R_log	log
190
#else
200
#else
191
double R_log(double x) { return(x > 0 ? log(x) : x < 0 ? R_NaN : R_NegInf); }
201
double R_log(double x) { return(x > 0 ? log(x) : x < 0 ? R_NaN : R_NegInf); }
Line 789... Line 799...
789
	    REAL(ans)[i] = myfmod(REAL(s1)[i1], REAL(s2)[i2]);
799
	    REAL(ans)[i] = myfmod(REAL(s1)[i1], REAL(s2)[i2]);
790
	}
800
	}
791
	break;
801
	break;
792
    case IDIVOP:
802
    case IDIVOP:
793
	mod_iterate(n1, n2, i1, i2) {
803
	mod_iterate(n1, n2, i1, i2) {
794
	    REAL(ans)[i] = floor(REAL(s1)[i1] / REAL(s2)[i2]);
804
	    REAL(ans)[i] = myfloor(REAL(s1)[i1], REAL(s2)[i2]);
795
	}
805
	}
796
	break;
806
	break;
797
    }
807
    }
798
 
808
 
799
    /* quick return if there are no attributes */
809
    /* quick return if there are no attributes */