I going to do a project. The output ADC is in binary like 00000001, so may i direct assign these binary value into a particular array? If yes, how i can take out the array content because i need to change the binary to decimal.
thank you..
I going to do a project. The output ADC is in binary like 00000001, so may i direct assign these binary value into a particular array? If yes, how i can take out the array content because i need to change the binary to decimal.
thank you..
No, you can't use a binary number directly in your C source file. You can, however, represent an octal or hex number directly in your program:
You can convert a binary number to an octal/hexadecimal number in your head, using a program of your own, or the Windows calculator (switch to Scientific mode).Code:printf("\222"); /* print octal 222*/ putchar(0xAb); /* print hex number AB */
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
The binary number 00000001 is pretty easy to represent in decimal, octal, or hexadecimal. 1, \001, or 0x1.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
ok...binary can not store in array..10s
let say the value array is hexadecimal because my system will direct and store the hexadecimal in array. i need to convert the hexadecimal to decimal. how can i get out the hexadecimal from the array? is it possible to get it out and then do conversion?
printf("%x")? sprintf()?
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.