Skip to content

Commit

Permalink
float return ZeroDivisionError when dividing by 0 in 1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
semmons99 committed Oct 13, 2011
1 parent a79f8c7 commit 2cf1a1e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions vm/builtin/float.cpp
Expand Up @@ -8,6 +8,7 @@
#include "vm.hpp"
#include "vm/object_utils.hpp"
#include "primitives.hpp"
#include "configuration.hpp"

#include <gdtoa.h>

Expand Down Expand Up @@ -118,6 +119,12 @@ namespace rubinius {
}

Array* Float::divmod(STATE, Float* other) {
if(LANGUAGE_19_ENABLED(state)) {
if(other->val == 0.0) {
Exception::zero_division_error(state, "divided by 0");
}
}

Array* ary = Array::create(state, 2);
ary->set(state, 0, Bignum::from_double(state, floor(this->val / other->val) ));
ary->set(state, 1, mod(state, other));
Expand Down

0 comments on commit 2cf1a1e

Please sign in to comment.