Design a function f(f(n)) == -n

Where n is a 32 bit signed integer.

Complex numbers arithmetic are forbidden.

Design it for the largest range possible, knowing that you can’t design it for the whole range of numbers.

The solution is to use Math Ceiling :

static double F(double n){
    if (n == 0) return 0;
    if (n < 0) return ((long)Math.Ceiling(n) % 2 == 0) ? (n + 1) : (-1 * (n - 1));
    else return ((long)Math.Floor(n) % 2 == 0) ? (n - 1) : (-1 * (n + 1));
}