Can't change a float

I’m trying to make a powerup that changes the speed of the character but for some reason it is giving me errors. Here’s the code:

public float speed = 1;

void OnCollisionEnter(Collision col)
{
     if (col.gameObject.name == "PowerUp")https://answers.unity.com/questions/ask.html#
     {
         speed = speed + 0.3;
     }
}

also I think you might need some "f"s after your float values or they read as “double” or “int”

speed = 1.0f;

speed += 0.3f;

public float speed;

void Awake()
{
speed = 1; 
}
 void OnCollisionEnter(Collision col)
 {
      if (col.gameObject.name == "PowerUp")
      {
          speed += 0.3f;
      }
 }