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 binary value to decimal

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



Joined: 19 Oct 2005
Posts: 2

View user's profile Send private message

Convert binary value to decimal
PostPosted: Wed Oct 19, 2005 10:10 am     Reply with quote

Hi,

I would like to convert binary value to decimal value. Do you know a function in CCS to realize this operation?

Thank you
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Wed Oct 19, 2005 10:21 am     Reply with quote

Use the Search feature of this forum and write the magic word "BCD", youŽll get
a lot of threads to read and learn how to.

Humberto
MikeValencia



Joined: 04 Aug 2004
Posts: 238
Location: Chicago

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Wed Oct 19, 2005 8:48 pm     Reply with quote

I would consult the 1st chapter in your introductory course to Digital Logic where they teach binary and decimal. Idea
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

Re: Convert binary value to decimal
PostPosted: Thu Oct 20, 2005 6:48 am     Reply with quote

bigoune wrote:
Hi,

I would like to convert binary value to decimal value. Do you know a function in CCS to realize this operation?

Thank you


Are you saying that you want to convert a string that is a representation of a binary number into an integer?
TIMT



Joined: 02 Sep 2005
Posts: 49
Location: Nottingham, UK

View user's profile Send private message

binary to decimal
PostPosted: Thu Oct 20, 2005 8:23 am     Reply with quote

Hi there I've attached some code done at home for converting the 10 bit binary code from the D to A in the pic to a decimal float. It will display the voltage on an lcd or whatever printf is. I wrote it for a 3volt full scale deflection. e.g 1111111111000000 (65472 in decimal) in long integer value (read from the a to d) represents 3volts... 65472/3 is 21824.
It works ok for me. My maths is not that good though so if there is a problem with it I deny all knowledge ! if it helps, use it

Tim


Code:


void dis_3v0_fsd(long int value)   // Function for sending voltage to LCD, 10 bit, 3.0V FSD.
{
       float disval;
       disval = value;
       disval = disval/21824;
       printf(lcd_putc,"%4.2fV",disval);
}

_________________
Tim
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