summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorGabriel Huber <mail@gabrielhuber.at>2021-04-30 22:39:25 +0200
committerGitHub <noreply@github.com>2021-04-30 22:39:25 +0200
commit34a09574ce4fd95a859d61ec234c37591e319e03 (patch)
treed0b8d74bcb8ba56e5740d87227fcd726f7b4341b
parentd0485e326ab56af367246227dedc088839678b6b (diff)
downloadNim-34a09574ce4fd95a859d61ec234c37591e319e03.tar.gz
Document the difference between toFloat/toInt and type conversion (#17894)
-rw-r--r--lib/system.nim5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/system.nim b/lib/system.nim
index 9e9bacf39..174630317 100644
--- a/lib/system.nim
+++ b/lib/system.nim
@@ -1472,7 +1472,7 @@ type # these work for most platforms:
   PInt32* = ptr int32        ## An alias for `ptr int32`.
 
 proc toFloat*(i: int): float {.noSideEffect, inline.} =
-  ## Converts an integer `i` into a `float`.
+  ## Converts an integer `i` into a `float`. Same as `float(i)`.
   ##
   ## If the conversion fails, `ValueError` is raised.
   ## However, on most platforms the conversion cannot fail.
@@ -1494,7 +1494,8 @@ proc toInt*(f: float): int {.noSideEffect.} =
   ##
   ## Conversion rounds `f` half away from 0, see
   ## `Round half away from zero
-  ## <https://en.wikipedia.org/wiki/Rounding#Round_half_away_from_zero>`_.
+  ## <https://en.wikipedia.org/wiki/Rounding#Round_half_away_from_zero>`_,
+  ## as opposed to a type conversion which rounds towards zero.
   ##
   ## Note that some floating point numbers (e.g. infinity or even 1e19)
   ## cannot be accurately converted.