Source: http://www.cnblogs.com/yinyueyouge/archive/2009/05/25/1488921.html
The independent variable mentioned in the original question is a 32-bit signed integer, Which is expanded here to discuss different defined values and value ranges.
Design a function f so that
F (f (x) =-x
The defined values and value ranges of f (x) are set.
(1)
If a is a complex number set C, then f (x) = I * X can be used. Where I is a virtual number unit, and I * I =-1 is used.
(2)
If a is an integer set Z
F (x) = 0, when x = 0,
F (x) = 1 + x, when x> 0 and is an odd number,
F (x) = 1-x, when x> 0 and is an even number,
F (x) =-1 + x, when x <0 and is an odd number,
F (x) =-1-x, when x <0 and is an even number,
Yi Zhi f (x) meets the requirements.
(3)
If a is a real number other than ± 1, that is, a = (-∞,-1) random (-) random (1, + ∞ ),
F (x) = 0, when x = 0,
F (x) = 1/X, when x ε (-) returns ),
F (x) =-1/X, when x ε (-∞,-1) returns (1, + ∞ ),
Then f (x) meets the requirements.
(4)
What if A is a real number set R or a rational number set Q?