You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pages/docs/arguments.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,17 +78,21 @@ llo
78
78
ld!
79
79
```
80
80
81
-
Functor **to_number(*string*)** transforms a string representing a number to its associated number.
81
+
Functor **to_number(*string*)** transforms a string representing a number to its associated number, it also recognises hex and binary numbers with a prefix.
82
82
```prolog
83
83
.decl tonumber(n:number)
84
84
.output tonumber
85
85
tonumber(n) :- n=to_number("123").
86
86
tonumber(n) :- n=to_number("1534").
87
+
tonumber(n) :- n=to_number("0xff").
88
+
tonumber(n) :- n=to_number("0b111").
87
89
```
88
90
The output would be:
89
91
```
90
92
123
91
93
1534
94
+
255
95
+
7
92
96
```
93
97
The reverse operation **to_string(*number*)** also exists, which turns a number to its string representation.
0 commit comments