summary refs log tree commit diff stats
diff options
context:
space:
mode:
authordef <dennis@felsin9.de>2015-01-03 05:09:56 +0100
committerdef <dennis@felsin9.de>2015-02-16 20:44:24 +0100
commitb1f4eda7238fd655f3e1d7213c6b78843e84b9e9 (patch)
tree1eeee47d8c405af61de9ac2214fb21b8f8222100
parentd57d1f00cd2c4a0023250ee0506c10393605f167 (diff)
downloadNim-b1f4eda7238fd655f3e1d7213c6b78843e84b9e9.tar.gz
Fix += and -= for Rational
-rw-r--r--lib/pure/rational.nim4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/pure/rational.nim b/lib/pure/rational.nim
index f04617dcd..edb0ca637 100644
--- a/lib/pure/rational.nim
+++ b/lib/pure/rational.nim
@@ -68,7 +68,7 @@ proc `+=` *(x: var Rational, y: Rational) =
 
 proc `+=` *(x: var Rational, y: int) =
   ## Add int `y` to rational `x`.
-  x.num += y
+  x.num += y * x.den
 
 proc `-` *(x: Rational): Rational =
   ## Unary minus for rational numbers.
@@ -101,7 +101,7 @@ proc `-=` *(x: var Rational, y: Rational) =
 
 proc `-=` *(x: var Rational, y: int) =
   ## Subtract int `y` from rational `x`.
-  x.num -= y
+  x.num -= y * x.den
 
 proc `*` *(x, y: Rational): Rational =
   ## Multiply two rational numbers.