View previous topic :: View next topic |
Author |
Message |
kmp84
Joined: 02 Feb 2010 Posts: 354
|
convert different data type... |
Posted: Mon Dec 12, 2011 3:02 pm |
|
|
Hi all!
I've this bytes "buffer" example: {0x20,0x20,0x20,0x20,0x34,0x35,0x36,0x31,0x34} which represent 0 0 0 0 4 5 6 1 4 or (4561.4). How to convert it into hex or dec. value and try to calculate percent of other value?
Thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Dec 12, 2011 3:19 pm |
|
|
Put a 0x00 on the end to make it into a string. Then use atof() to convert
the string to a float. Then divide the float by 10 to get the final number. |
|
|
kmp84
Joined: 02 Feb 2010 Posts: 354
|
|
Posted: Mon Dec 12, 2011 4:44 pm |
|
|
Thanks PCM programmer for your fast reply! All it's ok. |
|
|
|