0 C syntax question Posted by Limebear (Rob) on June 8, 2011 at 3:33pm Just reading the code for familiarisation. Could someone explain the syntax ".f" in the following line from ArducopterMega.pde please?G_Dt = (float)delta_ms_fast_loop / 1000.f; // used by DCM integrator Thanks You need to be a member of diydrones to add comments! Join diydrones Email me when people reply – Follow
Replies
The Arducopter code is C++ not C.
f = float qualifier
float is a 32 bits data type with 23 bits for mantissa 8 bits for exposant and 1 bit for sign.
By default, if you type a floating point value into C++ it’s typed as a double. Consequently, if you do something like this:
You’re assigning a double to a float, which loses precision, and the compiler will probably complain.
Putting an “f” after the value means that you intend that value to be a float, not a double.