$base » History » Version 7
Per Amundsen, 11/07/2018 01:11 PM
1 | 1 | Per Amundsen | _Added in 1.9.0_ |
---|---|---|---|
2 | |||
3 | *$base(N,inbase,outbase,zeropad,precision)* |
||
4 | |||
5 | Converts number N from inbase to outbase. The last two parameters are optional. |
||
6 | |||
7 | 6 | Per Amundsen | _In version 3.3+, it should work reliably to at least base64, otherwise to base32._ |
8 | |||
9 | 1 | Per Amundsen | *Parameters* |
10 | |||
11 | N - The number to convert. |
||
12 | inbase - The base to convert from. |
||
13 | outbase - The base to convert to. |
||
14 | 7 | Per Amundsen | zeropad - If length is higher than zeropad, pad numbers with zeroes to the specified zeropad length. |
15 | precision - Truncate fractions/decimal places to the specified precision. |
||
16 | 1 | Per Amundsen | |
17 | *Example* |
||
18 | |||
19 | <pre> |
||
20 | 5 | Per Amundsen | ; Returns F |
21 | 1 | Per Amundsen | //echo -ag $base(15,10,16) |
22 | |||
23 | 5 | Per Amundsen | ; Returns 1.8 |
24 | 1 | Per Amundsen | //echo -ag base(1.5,10,16) |
25 | |||
26 | 5 | Per Amundsen | ; Returns 002 |
27 | 1 | Per Amundsen | //echo -ag $base(2,10,16,3) |
28 | </pre> |