I am rebuiulding an old project that was made so long ago the best option for maths was the micromega FPU.
That little chip took care of parenthesis in calculations.
Now I have been playing with using something with an FPU to help with precision. To that i end a decided to have a bit of a test with a teensy 4.0 and FPU.
Now you can imagine i was expecting to handle parenthesis, apparently it does not. Below is the test code doing just one of the equations it will be doing.
While it's no hardship to seperate the thing within the parenthesis i just wanted to check that I had not done anything wrong before moving forward missing an obvious error.
If you are wondering, this is going to the control system for a macro rail with micron level resolution. The over plan is to have it so i can punch in a few values, it work out depth of feild, magnification and distance between shots.
That little chip took care of parenthesis in calculations.
Now I have been playing with using something with an FPU to help with precision. To that i end a decided to have a bit of a test with a teensy 4.0 and FPU.
Now you can imagine i was expecting to handle parenthesis, apparently it does not. Below is the test code doing just one of the equations it will be doing.
While it's no hardship to seperate the thing within the parenthesis i just wanted to check that I had not done anything wrong before moving forward missing an obvious error.
If you are wondering, this is going to the control system for a macro rail with micron level resolution. The over plan is to have it so i can punch in a few values, it work out depth of feild, magnification and distance between shots.
Code:
double DOF;
double DOF_1;
double DOF_2;
double one;
double two;
void setup()
{
Serial.begin(115200);
}
void loop()
{
DOF_1 = 2.0*10.0*0.019948*(1.5733333+1)/(5733333*5733333); // always return 0
one = 1.5733333+1.0;
two = 1.5733333*1.5733333;
DOF_2 = 2.0*10.0*0.019948*one/two; //returns correct value
//Serial.println(one,6);
//Serial.println(two,6);
Serial.println(DOF_1,6);
Serial.println(DOF_2,6);
Serial.println();
delay(1000);
}