It is not an exact science. It is relatively close though. Is your 21.5 hp engine net or gross. Is that based at 3600 rpm or 3100 rpm. Differences in carb, timing, valve lift, and duration can all effect the hp in the same displacement.
good example was the Kohler command 18,20,22 hp engines. The difference between the 18 and 20 was a screw in the side of the carb that preventing the throttle butterfly from opening more than halfway. The difference between the 20 and 22 was it added spark advance. All three engines used the same short block.