Skip to content

Commit

Permalink
docuement nim-lang#17208
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout committed Mar 2, 2021
1 parent 91abb08 commit b88fc7c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/pure/parseutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,10 @@ proc parseHex*[T: SomeInteger](s: string, number: var T, start = 0,
## or to the end of the string. Otherwise, no more than ``maxLen`` characters
## are parsed starting from the ``start`` position.
##
## It does not check for overflow. If the value represented by the string is
## too big to fit into ``number``, only the value of last fitting characters
## .. warning:: It does not check for overflow.
##
## If the value represented by the string is too big to fit into ``number``,
## only the value of last fitting characters
## will be stored in ``number`` without producing an error.
runnableExamples:
var num: int
Expand Down
6 changes: 6 additions & 0 deletions lib/pure/strutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,12 @@ func parseHexInt*(s: string): int {.rtl, extern: "nsuParseHexInt".} =
## If `s` is not a valid hex integer, `ValueError` is raised. `s` can have one
## of the following optional prefixes: `0x`, `0X`, `#`. Underscores
## within `s` are ignored.
##
## .. warning:: It does not check for overflow.
##
## If the value represented by the string is too big to fit into `int`,
## only the value of last fitting characters
## will be returned without producing an error.
result = 0
let L = parseutils.parseHex(s, result, 0)
if L != s.len or L == 0:
Expand Down

0 comments on commit b88fc7c

Please sign in to comment.