Hex>Dec conversion node

gweimer/utils now has a hex-to-number node for converting a hex string into a number. This will be useful for I2C address pins that require a decimal number, but users generally know the I2C address in hex.

“0x” prefix is required on input string. An invalid string will result in “random” output. Maybe I will get ambitious in the future and add error-checking and return -1 for invalid string if there are requests for it…

Currently input strings >15 characters will cause a buffer over-flow that is likely to cause very unpredictable results in your program.

String buffer is now dynamically allocated, so buffer over-flow will not be an issue.

Input string validation is now performed. If output is negative, the # indicates character position of error (1-based). i.e. “0001” will return -2 because 2nd char is not ‘x’. “0x0G” will return -4 because ‘G’ is not a valid HEX digit.

1 Like