Add for rationals

This commit is contained in:
def
2015-02-27 20:46:05 +01:00
parent 75959a0fb3
commit 4dbb582311

View File

@@ -28,6 +28,10 @@ proc `//`*[T](num, den: T): Rational[T] = initRational[T](num, den)
## .. code-block:: nim
## var x = 1//3 + 1//5
proc `$`*[T](x: Rational[T]): string =
## Turn a rational number into a string.
result = $x.num & "/" & $x.den
proc toRational*[T](x: SomeInteger): Rational[T] =
## Convert some integer `x` to a rational number.
result.num = x