muxer107
Newbie level 2
Hi all,
I have a pic18f4520 programmed with mplab X and the XC8 compiler. All variables are floats and i'm using it to solve the following polynomial:
X is typically around 200000.
Now, for a given change in X, Y should change appropriately, however Y is moving in jumps.
For example, instead of moving from 8488 to 8489 as X increases, it waits for X to increase enough, then jumps to 8502.
I know this is some sort of floating point issue (using such small numbers in the polynomial). However I can't put my finger on it, or even see how I can work around it.
Can anyone help?
Any input appreciated.
I have a pic18f4520 programmed with mplab X and the XC8 compiler. All variables are floats and i'm using it to solve the following polynomial:
Code:
poly1 = (-3.951941733344756E+04);
poly2 = (4.252156952428445E-01*X);
poly3 = (6.840575570401091E-08*X *X);
poly4 = (6.564136661977851E-15*X *X *X);
Y = (poly1+poly2+poly3+poly4);
X is typically around 200000.
Now, for a given change in X, Y should change appropriately, however Y is moving in jumps.
For example, instead of moving from 8488 to 8489 as X increases, it waits for X to increase enough, then jumps to 8502.
I know this is some sort of floating point issue (using such small numbers in the polynomial). However I can't put my finger on it, or even see how I can work around it.
Can anyone help?
Any input appreciated.