Skip to content

Commit 44fa8c9

Browse files
committed
merged main branch
Signed-off-by: Asif Bashar <asif.bashar@gmail.com>
1 parent 31f1b5f commit 44fa8c9

2 files changed

Lines changed: 67 additions & 264 deletions

File tree

docs/user/ppl/functions/conversion.md

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,70 @@ fetched rows / total rows = 1/1
269269
| TRUE |
270270
+-------------+
271271
```
272-
272+
273+
## TONUMBER
274+
275+
### Description
276+
277+
The following usage options are available, depending on the parameter
278+
types and the number of parameters.
279+
280+
Usage: tonumber(string, \[base\]) converts the value in first argument.
281+
The second argument describe the base of first argument. If second
282+
argument is not provided, then it converts to base 10 number
283+
representation.
284+
285+
Return type: Number
286+
287+
You can use this function with the eval commands and as part of eval
288+
expressions. Base values can be between 2 and 36. The maximum value
289+
supported for base 10 is +(2-2\^-52)·2\^1023 and minimum is
290+
-(2-2\^-52)·2\^1023. The maximum for other supported bases is 2\^63-1
291+
(or 7FFFFFFFFFFFFFFF) and minimum is -2\^63 (or -7FFFFFFFFFFFFFFF). If
292+
the tonumber function cannot parse a field value to a number, the
293+
function returns NULL. You can use this function to convert a string
294+
representation of a binary number to return the corresponding number in
295+
base 10.
296+
297+
Following example converts a string in binary to the number
298+
representation:
299+
300+
os> source=people | eval int_value = tonumber('010101',2) | fields int_value | head 1
301+
fetched rows / total rows = 1/1
302+
+-----------+
303+
| int_value |
304+
|-----------|
305+
| 21.0 |
306+
+-----------+
307+
308+
Following example converts a string in hex to the number representation:
309+
310+
os> source=people | eval int_value = tonumber('FA34',16) | fields int_value | head 1
311+
fetched rows / total rows = 1/1
312+
+-----------+
313+
| int_value |
314+
|-----------|
315+
| 64052.0 |
316+
+-----------+
317+
318+
Following example converts a string in decimal to the number
319+
representation:
320+
321+
os> source=people | eval int_value = tonumber('4598') | fields int_value | head 1
322+
fetched rows / total rows = 1/1
323+
+-----------+
324+
| int_value |
325+
|-----------|
326+
| 4598.0 |
327+
+-----------+
328+
329+
Following example converts a string in decimal with fraction to the
330+
number representation:
331+
332+
os> source=people | eval double_value = tonumber('4598.678') | fields double_value | head 1
333+
fetched rows / total rows = 1/1
334+
+--------------+
335+
| double_value |
336+
|--------------|
337+
| 4598.678 |
338+
+--------------+

docs/user/ppl/functions/conversion.rst

Lines changed: 0 additions & 263 deletions
This file was deleted.

0 commit comments

Comments
 (0)