View previous topic :: View next topic |
Author |
Message |
Joseph Guest
|
FMOD() utilisation - Division a float by a float |
Posted: Mon Apr 02, 2007 2:01 pm |
|
|
Hello !!! excuse for my english but I'm a french boy....
I'have got a problem, I want to make a simple division (Float by an another float) but impossible :
Here my script in few lines....Please help me....
//---------------------------------------
#include <16F877A.h>
#use delay(clock=20000000)
//----------------------------------------
#include "math.h"
#include "float.h"
//----------------------------------------
void main (void)
{
float result;
float val1=150.0;
float val2=0.54;
result=fmod(val1,val2); // At this line, the Step mode open the
// source code of "math.h" and stop
// the execution
}
I don't understand because the syntaxe is the same than CCS_manual.pdf
thanks before |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Apr 02, 2007 2:09 pm |
|
|
I tested your code with compiler vs. 3.249, and with MPLAB vs. 7.20.
It worked OK. I pressed the F8 key, to "Step over". It goes to the
fmod() routine in math.h, and then it goes to the floor() routine, and
then it exits math.h and goes back to the main() code.
What is your compiler version ? What is your version of MPLAB ?
Are you pressing the F8 key ? |
|
|
kevcon
Joined: 21 Feb 2007 Posts: 142 Location: Michigan, USA
|
|
Posted: Mon Apr 02, 2007 2:09 pm |
|
|
What did you get for result?
I got 0.419998169 |
|
|
Joseph Guest
|
|
Posted: Mon Apr 02, 2007 2:18 pm |
|
|
Ohhhhhhh oki
For me when I am in the code source of math.h its an error..... so the script is ok....thanks
But an another question.....150 / 0.54 = 277.77 and not 0.41 Why ???
I am a newbe..... |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
kevcon
Joined: 21 Feb 2007 Posts: 142 Location: Michigan, USA
|
|
Posted: Tue Apr 03, 2007 7:14 am |
|
|
I noticed that too, the result int this case should be 0.42 not 0.419998169 |
|
|
|