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

float type pointers

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








float type pointers
PostPosted: Mon Nov 06, 2006 2:39 pm     Reply with quote

Hello,

I can not seem to get the correct results when working with float type variable. I have an example of what i am trying to do below. first passing a some float parameters and observing the result, doing the same operation without passing. Is there something that i am missing??

Code:

 #include <16F877>
#device *=16
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT,NOPUT,NOPROTECT,NOWRT,NOCPD
#use delay(clock=20000000)

void point_back_float(float *a, float *b, float *c){
*c = a/b;
}

void main(){

float a=3.0,b=10.0,c = 0;

point_back_float(&a,&b,&c);     //pass operation

c = a/b;    //internal operation

}

PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Nov 06, 2006 2:54 pm     Reply with quote

If you pass everything with a pointer, then you have to de-reference
everything. Example of how to fix it:
Code:
*c = (*a)/(*b);
Guest








PostPosted: Mon Nov 06, 2006 3:13 pm     Reply with quote

durrr, love it when i overlook the details. One of those days!

Thank you
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