HEX to decimal

personal_username's icon

Hi all!

I searched the forum, but couldn't find anything about a tool for converting HEX into decimal
I can easily set a regular [int] to output hex instead of decimals, but not the other way around...

Any tip?

hz37's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Set an integer box to hex in the inspector and connect it to one that's decimal (integer). Voila, work done! You can type FF or 2E in your hex box and it will output the corresponding base10 number in a connected int box. If, however, you want to send a set message with a hex literal to an int box set to hex notation, that won't work directly. In fact, you can still send decimal notation to a hex int and it will convert it. You can use C-style hex (prefixing 0x, e.g. 0xff) but this will automagically convert to decimal once typed into a message box. A way out is to use a lilteral string, like "0xff" and convert it from a symbol. Hope this helps!

personal_username's icon

Thanks a lot HZ37,

Max Patch
Copy patch and select New From Clipboard in Max.

that was really useful!
At the end I ended up with this, not sure if it's the best possible way... but it does work! ;-)

Peter Castine's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Or like this?