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 CCS Technical Support

hi, i have some problems with math.h

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



Joined: 26 Oct 2005
Posts: 4

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

hi, i have some problems with math.h
PostPosted: Wed Oct 26, 2005 3:43 pm     Reply with quote

hello , i was working with math.h header file in pcwh 3.207 compiler , when i use the wizard its works. but when i dont use the wizard and i include the library it dont work.

my code is :

#device PIC16F877

#include <defs_877.h>
#include <lcd_out.h>
#include <lcd_out.c>
#include <math.h>

void main(void)
{

float p;



while(1)
{

lcd_cursor_pos(0, 0);

printf(lcd_char, "multiplicacion 5*2.5");
lcd_cursor_pos(2, 0);

p = 5-2.5;

printf(lcd_char," p = %f", p);
}
}

I'm a new user of ccs, someone can help me
thanks for all
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 26, 2005 3:53 pm     Reply with quote

Quote:
it dont work.

Explain what you expect to see, and tell us what you actually see.
Guest








PostPosted: Wed Oct 26, 2005 6:09 pm     Reply with quote

Code:

p = 5-2.5;


maybe your problem is that you are subracting when you are trying to multiply?

a better way (expliclty express types):
Code:

p = 5.0 * 2.5;
or
p = (double)5 * 2.5;


also you do not need math.h to do basic arithmetic in c.
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