Do any of you know how this will be calculated in C?
uint8_t samplerate = 200;
uint8_t Result;
Result = 0.5 * samplerate;
Now, the problem is t
Yes, of course this is controlled by the standard, there is no uncertainty here.
Basically the integer will be promoted to double
(since the type of 0.5
is double
, it's not float
) and the computation will happen there, then the result will be truncated back down to uint8_t
. The compiler will shout at you for the loss of precision, typically. If it does not, add more warning options as required.