Why do I need the "f" when using a float?

The variable “speed”, near the bottom when I subtract .5 from it it requires that “f”, why is that? It was already declared a float in the beginning of the code.

using UnityEngine;
using System.Collections;

public class Player : MonoBehaviour
{
	float speed = 0;
	float max_speed = 5;
	float accel = 1;
	
	// Use this for initialization
	void Start ()
	{
	}
	
	// Update is called once per frame
	void Update ()
	{
		if (Input.GetKey (KeyCode.W))
		{
			if (speed < max_speed) { speed += accel * Time.deltaTime; } else { speed = max_speed; }
			transform.Translate (0, 0, speed * Time.deltaTime);
		}
		if (Input.GetKey (KeyCode.S))
		{
			transform.Translate (0, 0, -3 * Time.deltaTime);
		}
		if (Input.GetKey (KeyCode.A))
		{
			transform.Translate (-3 * Time.deltaTime,0 , 0);
		}
		if (Input.GetKey (KeyCode.D))
		{
			transform.Translate (3 * Time.deltaTime,0 , 0);
		}
		
		if (speed > 0) { speed -= .5f * Time.deltaTime; }
	}
}

You need it because in C# .5 is a double not a float and the compiler will complain that you are losing precision. .5f indicates a float and so it is the same type.

Your declaration that the variable speed is of type float.
It assigns the value 0.5 to this variable.

According to the C# specification, a number containing a decimal point that doesn’t have a suffix is interpreted as a double.

So we now have a double value that we want to assign to a variable of type float. In order to do this, there must be an implicit conversion from double to float. There is no such conversion, because you may (and in this case do) lose information in the conversion.

The reason is that the value used by the compiler isn’t really 0.5, but the floating-point value closest to 0.5, which is 0.4999999999999978655962351581366… for double and exactly 0.499999946057796478271484375 for float.

Strictly speaking, the f is not required. You can avoid having to use the f suffix by casting the value to a float:

float speed= (float)0.5;