Hi. I want to know if exists a instruction that permit convert a decimal number to a binary. My problem is that I receive a data from rs232 in decimal and I need it in binary.
thanks all
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
Posted: Sun Dec 18, 2011 10:49 pm
Do you mean the decimal data is in ASCII character form? _________________ Google and Forum Search are some of your best tools!!!!
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
Posted: Mon Dec 19, 2011 7:08 am
as mentioned before, you need to be clear if the data is comming as ASCII or not..
if its ascii numbers, just substract 30...(0-9) - for letters... its somthing similar...
please take into acount that once you "translate" your Ascii to hex, its already in binary....
you can perform bitwise operations on hex numbers...like if they where binary... although you "see" 0xAB you in reality have "b10101011"
the complier does all the work for you...
int x = 10; // Dec
int x = 0x0A; // Hex
int x = b00001010; // bin
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum