Detonation is chiefly caused by octane.
The octane number is the percentage of octane in a mixture of iso-octane and iso-heptane.
To calculate the octane number of a fuel, an engine is run with the fuel. Trials are conducted in which detonation occurs in the engine.
The engine is then run with different mixtures of iso-octane and iso-heptane in the same conditions. The trial is repeated with different mixtures. The conditions at which knocking occurs are noted.
The combination of iso-octane and iso-heptane which causes knocking at the same conditions as that of the fuel is identified.
For instance, let us say that a combination of 65% iso octane and 35% iso heptane causes knocking in the same conditions as that of the fuel.
Then, the fuel is said to have an octane number of 65.