I'm new to c++ and I'm trying to convert a double to hex and split it.
For example if the double is 1 it needs to be converted to hex and splitted to 2 char var1 0 and char var2 1
If the double is 10 the hex converted should be A and then splitted into char var1 0 and char var2 A
if the double is 250 the hex converted would be FA and then splitted into char var1 F and char var2 A
I'm programming a midi conversion for a synth so the max notenumber would never go beyond 255
I already figured out how to cast the double to char but i'm complete lost on how to do the split...
Your code actually works perfect (my code above only works untill 127) but when i insert the variables into this matrix they come out not in a hex format
Post your whole code so that we can see what's going on. If you need to deal with a value between 128 and 255 then you need to cast to unsigned - like I did in my code L8. char is a signed type and has values -128 to 127. unsigned char has values 0 to 255
Ok, so I'm reading a midi note, this an int from 0 to 120, then I do a calculation on it to send it to a synth. I need to convert it from 0/120 to 0/255: