How can I change the notation of a Integer value, t.e.:
(Integer -> hexadecimal notation)
How can I change the notation of a Integer value, t.e.:
(Integer -> hexadecimal notation)
There is another way, with the iq-text element which support the execution of JS functions.
/**
Converts an interger number to a HEX string
* @example
* x = Int2Hex(255, 4)); // x = "00FF"
*
* @param {number} iVal Number to convert
* @param {number} iLen length of converted string
* @returns {string} HEX string of iVal
*/
function Int2Hex(iVal, iLen) {
return iVal.toString(16).toUpperCase().padStart(iLen, "0");
}
/**
* Converts iVal into binary string
* @example
* x = Int2Bin(3, 4)); // x = "0011"
*
* @param {number} iVal Number to convert
* @param {number} iLen length of converted string
* @returns {string} HEX string of iVal
*/
function Int2Bin(iVal, iLen) {
return iVal.toString(2).padStart(iLen, "0");
}