1

When multiplying a zero x or y value of a CGPoint variable with -1, the resulting value is -0. Is this intended behavior?

I think that's odd, it took me quite some time to find that out. I use Swift 3.1 in Xcode 8.3.2.

Alessandro Ornano
  • 34,887
  • 11
  • 106
  • 133

1 Answers1

2

CGPoint's x and y are CGFloats, which means they are floating point scalar values. And in floating point arithmetic, zero also has a sign, so that multiplying it by a negative value results in a zero with opposite sign.

For further reading you can check these: https://developer.apple.com/reference/swift/floatingpointclassification https://en.wikipedia.org/wiki/Signed_zero

user3581248
  • 964
  • 10
  • 22