hex to decimal
This function converts a hexadecimal sequence to a number. Range: : 64-bit integer boundary, i.e. max 16 hexadecimal symbols.
Negative hexadecimal values, e.g. -0A1, are not allowed. In fact, all non-hexadecimal characters including the minus sign
will be ignored, allowing to convert values conveniently such as 0x10ac, #10ac, b>10 ac, etc.
Vectorization: This function supports vectorization in the 1st function parameter.
Instead of providing a single value, you can provide a set or even a nested set which contain multiple values.
The function will then process every value and its return value contains a corresponding set containing all results.
Indirect parameter passing is disabled
Vectorization is allowed in the 1st function parameter
1-3
No. | Type | Description |
---|---|---|
1. input |
string set |
Hexadecimal value Hexadecmial digits are 0..9 and A..F or a..f or a combination of them. Other characters and spaces will be ignored. Multiple values can also be provided in a paramter set (vectorization). |
Opt. 2. input |
numeral | Starting character position Optionaly specify the 1st character position to start decoding, i.e. skip string contents before that position Default value: 0 |
Opt. 3. input |
numeral | Character count You can limit the number of character to decode. This is useful for working with long strings containing more than just a hexadecimal value. Default value: (not limited) |
Type | Description |
---|---|
numeral set |
Decoded value Converted from the hexadecimal number. 0 is returned if contents are blank or contain no hexadecimal digits. |
Values provided is not a numerals
examples[] = { 20AC, 0x20AC, 20ACH, "#20AC", "", "-" };
for all( examples[], h[] )
{
print( hex to decimal( h[] ), " " );
echo( "2nd char pos, len = 1: ", hex to decimal( h[], 2, 1 ) );
}
echo("Using vectorization: ", hex to decimal( examples[] ) );
8364 2nd char pos, len = 1: 10
8364 2nd char pos, len = 1: 2
8364 2nd char pos, len = 1: 10
8364 2nd char pos, len = 1: 0
0 2nd char pos, len = 1: 0
0 2nd char pos, len = 1: 0
Using vectorization: {8364,8364,8364,8364,0,0}