Converting from base10 to base16 and save it in unsigned char array?
-
Hello, I would like to convert a decimal number (base10) into hexadecimal and then save it into an unsigned char array. I have an integer whose value increments from 1024 to a max of 2047 in steps of 1 whenever the user clicks a button. At each step I need to convert it to a hexadecimal number and save it into an unsigned char array or 2 elements so that I can send it to a device via USB. For example: If I want to send 1955 decimal number I would like to have my unsigned char array as below Out[0] = 0x07; out[1] = 0xA3 then I can use my transferdata(out) function. Can someone help me with this? thanks in advance
PKNT
-
Hello, I would like to convert a decimal number (base10) into hexadecimal and then save it into an unsigned char array. I have an integer whose value increments from 1024 to a max of 2047 in steps of 1 whenever the user clicks a button. At each step I need to convert it to a hexadecimal number and save it into an unsigned char array or 2 elements so that I can send it to a device via USB. For example: If I want to send 1955 decimal number I would like to have my unsigned char array as below Out[0] = 0x07; out[1] = 0xA3 then I can use my transferdata(out) function. Can someone help me with this? thanks in advance
PKNT
-
Something like ...
Out[0] = decimalNumber / 256;
Out[1] = decimalNumber % 256;One of these days I'm going to think of a really clever signature.
Thanks for your reply, it works perfect. Looks very simple, wonder why I didnt get that idea (I did many times before in similar ways). These days I have to start thinking from scratch. :)
PKNT
-
Thanks for your reply, it works perfect. Looks very simple, wonder why I didnt get that idea (I did many times before in similar ways). These days I have to start thinking from scratch. :)
PKNT