CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

convert different data type...

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
kmp84



Joined: 02 Feb 2010
Posts: 345

View user's profile Send private message

convert different data type...
PostPosted: Mon Dec 12, 2011 3:02 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Dec 12, 2011 3:19 pm     Reply with quote

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: 345

View user's profile Send private message

PostPosted: Mon Dec 12, 2011 4:44 pm     Reply with quote

Thanks PCM programmer for your fast reply! All it's ok.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group