Award
Congratulations DJ Sures, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here.

How To Convert Integer To Hex

Assistance Requested

Help OldBotBuilder with their question and receive $10 of EZ-Credit to get more robots and parts from our store. The following information was provided about their previous efforts searching tutorials for a resolution.

OldBotBuilder claims to have checked these sources:
 
#1

I wish to convert an integer to Hex. For instance, if I subtract one Hex value from another Hex value, the result is an integer. I would like to get the Hex value of that integer.

Here is the code I have tried:

Code:


$val = (0xff - 0x28)
print($val)

$hex = ToHex($val)
print($hex)



The results I get are:
start
1: $val = (0xff - 0x28)
2: print($val)
>215

The results I want are: $hex = 0xD7

I have found a few conversations, tutorials and activities that may help with your question. Take a look at these links. I've sorted them by what I believe to be most relevant but that is not always the case as I'm still learning.


Also, consider reviewing the Learn section for informative lessons and activities. Check it out!


#2

How about this command ***edit*** never mind, I see you know of the command already

Code:


$hex=ToHex( value ) #converts an integer to hex

#3

Thanks - I found that PrintHex() has a bug because it prints each digit of the value. It's fixed for next release.

#4

Thanks DJ.
Looking forward to the next release.

#5

It'll probably be midnight tonight. I've been working on an update that stores the Example Projects in an All Users folder for public sharing between accounts. It's been requested by schools to share the examples folder - so hopefully that'll be done by this evening and will include your fix

#6

Latest release fixes PrintHex()

Release notes: http://www.ez-robot.com/Community/Forum/Thread?threadId=7596