The V8 engine code used in the E39 M5 is S62, more precisely S62B50.
The naturally aspirated 4.9-litre V8 powered the third-generation M5, built from 1998 to 2003. BMW’s full designation, S62B50, identifies it as an M-developed engine with an approximately 5.0-litre displacement designation, although its actual capacity is 4,941 cc.
The S62 combined double overhead camshafts, four valves per cylinder and BMW’s VANOS variable camshaft timing. It also used individual throttle butterflies and a distinctive cross-bolted construction, helping produce roughly 400 horsepower in European-market specification and making the E39 M5 both a luxury sedan and a serious performance car.
The shorter answer “S62” is the engine-family code commonly used in discussions, parts listings and enthusiast communities. It should not be confused with the later S65 V8 from the E9x M3, the turbocharged N63 family, or the non-M M62 V8. The related Z8 roadster also used an S62-based engine.