Avisaro Online Documentation - Wiki
Impressum Kontakt Sitemap

HEX$

Description

HEX$ is a function that generates strings which are a hexadecimal (a radix16 numeral system) representation of the input value.

HEX$ requires two arguments. The first one is a number (constant or variable), which should be converted into a hex string. The other argument is the number of hexadecimal digits, that is, the length of the output string. This number can be any value between 1 and 8 (inclusive).

If the second argument demands more digits than the raw conversion would produce, the output is filled up with leading zeros. On the other hand, if the second argument demands fewer digits than the conversion would produce, the output is truncated to keep only the low-order bytes. If the second argument is out of range, the output is forced to be always 8 digits in length.

Example

This little example prints the hexadecimal value of the number 255 as a four-digit hex string. The output will be 00ff

outmode -2
let a = 255
print hex$(a,4)
end

Remarks

The output contains only hex digits. There's no leading "0x" as there is in C-style programming languages.