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)); }
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; }
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); }
extern "C" double div_float_float(double lhs, double rhs) { raiseDivZeroExcIfZero(rhs); return lhs / rhs; }
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); }
extern "C" double floordiv_float_float(double lhs, double rhs) { raiseDivZeroExcIfZero(rhs); return floor(lhs / rhs); }