1
1
mirror of https://github.com/wader/fq.git synced 2024-12-25 22:34:14 +03:00
fq/pkg/interp/testdata/funcs.fqtest
Mattias Wadman 26d9650b0e interp: Refactor radix* into toradix($base)/fromradix($base)
There is also toradix($base; $table)/fromradix($base; $table) for custom symbols and bases.
Add radix tests

Part of cleaning up all convert/tranformation functions into to/from*.

Remove number_to_bytes as with better binary support it can be written as:
1234 | tobytes | [.[range(.size)]] and soon as 1234 | tobytes | explode
2022-02-11 01:28:39 +01:00

30 lines
884 B
Plaintext

$ fq -i
null> "abc" | topem
"-----BEGIN-----\nYWJj\n-----END-----\n"
null> "abc" | topem | "before" + . + "between" + . + "after" | frompem | tostring
"abc"
"abc"
null>
null> (0,1,1024,99999999999999999999) as $n | (2,8,16,62,64) as $r | "\($r): \($n) \($n | toradix($r)) \($n | toradix($r) | fromradix($r))" | println
2: 0 0 0
8: 0 0 0
16: 0 0 0
62: 0 0 0
64: 0 0 0
2: 1 1 1
8: 1 1 1
16: 1 1 1
62: 1 1 1
64: 1 1 1
2: 1024 10000000000 1024
8: 1024 2000 1024
16: 1024 400 1024
62: 1024 gw 1024
64: 1024 g0 1024
2: 99999999999999999999 1010110101111000111010111100010110101100011000011111111111111111111 99999999999999999999
8: 99999999999999999999 12657072742654303777777 99999999999999999999
16: 99999999999999999999 56bc75e2d630fffff 99999999999999999999
62: 99999999999999999999 1V973MbJYWoT 99999999999999999999
64: 99999999999999999999 1mL7nyRz3___ 99999999999999999999
null> ^D