The corresponding "atomikky" predicate, however, is called atom_number/2
Note that unlike other predicates, the String must indeed be a string, an atom is not accepted (at least for now). However, list of characters (atoms of length 1) and list of unicode code points are allowed:
:- begin_tests(number_string). test("usual case", true(S == "123456")) :- number_string(123456,S). test("usual case, with leading 0s", true(S == "123456")) :- number_string(0000123456,S). test("parsing integer", true(N == 123456)) :- number_string(N,"123456"). test("parsing integer with leading 0s", true(N == 123456)) :- number_string(N,"0000123456"). test("no leading whitespace in string", fail) :- number_string(_," 123456"). test("no trailing whitespace in string", fail) :- number_string(_,"123456 "). test("fails if string-to-parse is not a number (rather than throwing) #1", fail) :- number_string(_,"NaN"). test("fails if string-to-parse is not a number (rather than throwing) #2", fail) :- number_string(_,"Hello, World!"). test("direct verification") :- number_string(123456,"123456"). % --- % UNEXPECTED: "Type error: `list' expected, found `'123456'' (an atom)" % --- test("weird exception 1", true(N == 123456)) :- number_string(N,'123456'). % --- % UNEXPECTED: "Type error: `list' expected, found `'0000123456'' (an atom)" % --- test("weird exception 2", true(N == 123456)) :- number_string(N,'0000123456'). % --- % The above is explained by the fact that number_string/2 can actually process % lists of unicode code points or characters to represent valid numbers, too: % --- test("Bad code points", fail) :- number_string(_,[1,2,3]). test("Good list of characters", true(N == 123)) :- number_string(N,['1','2','3']). test("A conversion too far: list of stringy characters", [error(type_error(_,_))]) :- number_string(_,["1","2","3"]). test("Good list of code points #1", true(N == 123)) :- number_string(N,[0'1, 0'2, 0'3]). test("Good list of code points #2", true(N == 123)) :- number_string(N,[0'0, 0'0, 0'1, 0'2, 0'3]). :- end_tests(number_string).