module FDB::Tuple

def self._compare_floats(f1, f2, is_double)

def self._compare_floats(f1, f2, is_double)
  # This converts the floats to their byte representation and then
  # does the comparison. Why?
  #   1) NaN comparison - Ruby doesn't really do this
  #   2) -0.0 == 0.0 in Ruby but not in our representation
  # It would be better to just take the floats and compare them, but
  # this way handles the edge cases correctly.
  b1 = float_adjust([f1].pack(is_double ? ">G" : ">g"), 0, (is_double ? 8 : 4), true)
  b2 = float_adjust([f2].pack(is_double ? ">G" : ">g"), 0, (is_double ? 8 : 4), true)
  b1 <=> b2
end