[System.Numerics] Ported code from MS referencesource

Relies on https://github.com/mono/referencesource/pull/1, do not merge until that merged.