14

I find it weird that for C floats, -0<+0 is not true. Had to write a little bit of extra code to enforce this.

-0 could represent an incrementally small number below zero but greater than the next lower quantisation level.

Comments
  • 2
    @mysth +0 is just 0. -0 (0x80000000) is the only extra thing that we have to deal with.
  • 1
    < is orderable and implies not > and not ==
    > is orderable and implies not ==
    == is an equivalence relation
    < U > U == includes all pairs of numeric types

    A language that doesn't respect set theory is a bad language.
  • 0
    @inawhile Mathematically yes. That much is obvious. But in C, -0 does not equal +0. Also, 0 is still 0 nobody is disputing it. It’s just about where we put -0 (0x80000000) on the number line for the purposes of the comparison operator.
  • 2
    @r20408e122449d If -0 doesn't equal +0 in C then C is breaking the floating point specification.
Add Comment