最初我认为Math.Sign这是正确的方法,但在运行测试之后,似乎它对待-0.0和+0.0相同.
Math.Sign
-0.0
+0.0
.net c# floating-point
C#中的零(-0)等于零(0)?
c#
c# ×2
.net ×1
floating-point ×1