Why is this little bit of math returning infinity???

Hi there and thanks for looking.

Here is my problem i want to work out a percentage of a number and add it to another variable here is my code public float l_Damage;

void MeleeDamage()
	{
		l_Damage = Random.Range(damageMin, damageMax);
		damage = l_Damage;
		if(inventorySystem.currentlySelectedWeapon.weaponType == PlayerWeapons.WEAPONTYPES.TwoHandedWeapon)
		{
			Debug.Log("#Damage is this before the call " + l_Damage);
			l_Damage /= barbarian.damageIncreaseWith2HWeapons;
			Debug.Log("Damage is this after the call " + l_Damage);
			
			damage += l_Damage;
			Debug.Log(damage);
		}
	}

For some reason i keep getting a infinity in the inspector

What i want to do is something like this.

Damage = 4.2;
modifier = 10;

l_modifier = damage / modifier.

which should give me 0.42 then add this to the damage variable but it’s not working like this.

Infinity is returned when a DivisionByZero is performed (in most cases). Therefore you have to check the value of barbarian.damageIncreaseWith2HWeapons before attempting the division.

Something like:

if( barbarian.damageIncreaseWith2HWeapons > 0.1f )
{
    l_Damage /= barbarian.damageIncreaseWith2HWeapons;
}