What is the minecraft armor equation

I know minecraft armor and that half a armour bar stops 4% of the damage. But I dont quite understand how the equation is done. If someone could comment an example that would be great.!(Like the equation but answer it like you have diamond armour and a diamond sword)


The Official Minecraft Wiki gives an exact formula of how damage is applied:

enter image description here

However, this formula is only applicable to Java editions of Minecraft.

If you are on Bedrock, then each defense point provides a flat 4% damage reduction. For example, in Bedrock, standard leather armor gives a flat 28% damage protection.