The HP depends on the method used to measure it. UK is using DIN more commonly now, but it used to use SAE, so our figure of 338bhp for the S54 in a Z4M seems lower than the 343bhp for the S54 in an e46 M3. However, that 5bhp loss is down to the standard used, rather than anything to do with the engine's actual power output.
I believe the US one is 333(SAE)/328(DIN) and the EU/UK one is 343(SAE)/338(DIN).
To convert DIN to SAE you multiply the DIN number by 1.014, or divide by the same figure to go from SAE to DIN.