Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Divide is done in float type for skime.

  • Loading branch information...
commit e17b6f7175812fb9d5669f6e85916579fe3c049c 1 parent 41044a8
@pluskid authored
Showing with 6 additions and 2 deletions.
  1. +3 −1 skime/prim.py
  2. +3 −1 tests/test_primitive.py
View
4 skime/prim.py
@@ -181,7 +181,9 @@ def minus(vm, num, *args):
@type_error_decorator
def div(vm, num, *args):
if len(args) == 0:
- return 1/num
+ return 1.0/num
+ if isinstance(num, (int, long)):
+ num = float(num)
for x in args:
num /= x
return num
View
4 tests/test_primitive.py
@@ -27,7 +27,9 @@ def test_basic(self):
assert self.eval('(*)') == 1
assert self.eval('(/ 6 3)') == 2
- assert self.eval('(/ 2)') == 0
+ # skime has no rational type, divid is
+ # done in float type
+ assert self.eval('(/ 2)') == 0.5
assert self.eval('(/ 2.0)') == 0.5
assert_raises(WrongArgNumber, self.eval, '(/)')
Please sign in to comment.
Something went wrong with that request. Please try again.