Permalink
Browse files

float return ZeroDivisionError when dividing by 0 in 1.9

  • Loading branch information...
1 parent a79f8c7 commit 2cf1a1e064844160a734bebfe53ed7529bea6065 @semmons99 semmons99 committed Oct 13, 2011
Showing with 7 additions and 0 deletions.
  1. +7 −0 vm/builtin/float.cpp
View
@@ -8,6 +8,7 @@
#include "vm.hpp"
#include "vm/object_utils.hpp"
#include "primitives.hpp"
+#include "configuration.hpp"
#include <gdtoa.h>
@@ -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));

0 comments on commit 2cf1a1e

Please sign in to comment.