When floating-point variable assignment is combined with integer variable, it is necessary to add 0.5 before assignment for rounding.
The display can be set to three decimal places.
printf("\nspeed=%.3f\n ",speed);
If you really need a very accurate decimal and the numerical range is not very large, you can consider using integer variables instead of floating-point numbers.
For example, uint speed=32 1 123 is commonly used in applications to represent floating-point numbers 32 1. 123, such as variables representing prices.