|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
float type pointers |
Posted: Mon Nov 06, 2006 2:39 pm |
|
|
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
|
|
Posted: Mon Nov 06, 2006 2:54 pm |
|
|
If you pass everything with a pointer, then you have to de-reference
everything. Example of how to fix it:
|
|
|
Guest
|
|
Posted: Mon Nov 06, 2006 3:13 pm |
|
|
durrr, love it when i overlook the details. One of those days!
Thank you |
|
|
|
|
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
|