3

I know of these values:

  • CGFloat.infinity, which is greater than
  • CGFloat.greatestFiniteMagnitude, which is greater than
  • CGFloat.leastNormalMagnitude, which is greater than
  • CGFloat.leastNonzeroMagnitude, which is greater than
  • 0

but it stops there... as far as I can tell. Where are the negative values? I imagine maybe it's as easy as placing a - before them, but then I worry that there might be strange exceptions.

How do I find the key negative numbers in CGFloat? Critically, the lowest negative non-infinite number.

Ky -
  • 30,724
  • 51
  • 192
  • 308

1 Answers1

13

Floating point numbers have a sign bit and negating them changes this sign bit to the opposite value (there is actually a negative zero).

Just put a minus before them. The negation is well defined.

Sulthan
  • 128,090
  • 22
  • 218
  • 270