GoForSmoke:
// why not
int v = (int) ( 4000UL * z / x ); // it does the math in 32 bit unsigned THEN casts the result to signed 16 bit.One answer is variable types and casting.
Also AVR has no FPU and only has 32 bit floats whereas Arduino supports 64 bit integers good to 19 places and can do those faster than floats good to 6 places, here's the missing:
I have much to learn, can you please verify my assumptions of what just happened?
Referring to: int v = (int) ( 4000UL * z / x )
"int v" declared an integer variable as usual
"(int)" requested int output?
"(4000UL * z / x)" the operation in the parentheses uses more math friendly 32-bit stuff; the #UL just declares that 4000 as an unsigned long