JanetDocsPlaygroundI'm feeling luckyGitHub sign in

scan-number



    cfunction
    src/core/corelib.c on line 382, column 1

    (scan-number str &opt base)

    Parse a number from a byte sequence and return that number, either 
    an integer or a real. The number must be in the same format as 
    numbers in janet source code. Will return nil on an invalid number. 
    Optionally provide a base - if a base is provided, no radix 
    specifier is expected at the beginning of the number.


3 examplesSign in to add an example
Loading...
(scan-number "1_000_000")
# => 1000000
sogaiuPlayground
(scan-number "111" 2)
# => 7
sogaiuPlayground
(scan-number "123") # => 123
(scan-number "f") # => nil

(scan-number 123) # =>
# error: bad slot #0, expected string|symbol|keyword|buffer, got 123
#   in scan-number
#   in _thunk [repl] (tailcall) on line 1, column 1
swlkrPlayground