Don't fail on mod == 0 (in weird cases where the given UNSIGNED_TYPE_MAX == SIGNED_TYPE_MAX) but res = mod > 0 ? (1u * res % mod) : res;
Don't fail on mod == 0 (in weird cases where the given UNSIGNED_TYPE_MAX == SIGNED_TYPE_MAX) but res = mod > 0 ? (1u * res % mod) : res;