Ejemplo n.º 1
0
extern "C" Box* floatFloorDiv(BoxedFloat* lhs, Box *rhs) {
    assert(lhs->cls == float_cls);
    if (rhs->cls != float_cls) {
        return NotImplemented;
    }
    BoxedFloat *rhs_float = static_cast<BoxedFloat*>(rhs);
    raiseDivZeroExcIfZero(rhs_float->d);
    return boxFloat(floor(lhs->d / rhs_float->d));
}
Ejemplo n.º 2
0
extern "C" double mod_float_float(double lhs, double rhs) {
    raiseDivZeroExcIfZero(rhs);
    double r = fmod(lhs, rhs);
    // Have to be careful here with signed zeroes:
    if (std::signbit(r) != std::signbit(rhs)) {
        if (r == 0)
            r *= -1;
        else
            r += rhs;
    }
    return r;
}
Ejemplo n.º 3
0
extern "C" Box* floatDivInt(BoxedFloat* lhs, BoxedInt *rhs) {
    assert(lhs->cls == float_cls);
    assert(rhs->cls == int_cls);
    raiseDivZeroExcIfZero(rhs->n);
    return boxFloat(lhs->d / rhs->n);
}
Ejemplo n.º 4
0
extern "C" double div_float_float(double lhs, double rhs) {
    raiseDivZeroExcIfZero(rhs);
    return lhs / rhs;
}
Ejemplo n.º 5
0
extern "C" Box* floatRDivFloat(BoxedFloat* lhs, BoxedFloat *rhs) {
    assert(lhs->cls == float_cls);
    assert(rhs->cls == float_cls);
    raiseDivZeroExcIfZero(lhs->d);
    return boxFloat(rhs->d / lhs->d);
}
Ejemplo n.º 6
0
extern "C" double floordiv_float_float(double lhs, double rhs) {
    raiseDivZeroExcIfZero(rhs);
    return floor(lhs / rhs);
}