Skip to content
This repository
Browse code

Eschew the use of == on FLOATVALs, @pmichaud++

  • Loading branch information...
commit 94e7f64c49b9fabcd8077c736fe449f69200c67b 1 parent 8c9a371
Duke Leto leto authored

Showing 1 changed file with 2 additions and 3 deletions. Show diff stats Hide diff stats

  1. +2 3 src/pmc/fixedfloatarray.pmc
5 src/pmc/fixedfloatarray.pmc
@@ -594,9 +594,8 @@ static int
594 594 auxcmpfunc(ARGIN(const FLOATVAL *i), ARGIN(const FLOATVAL *j))
595 595 {
596 596 ASSERT_ARGS(auxcmpfunc)
597   - if (*i == *j) return 0;
598   - if (*i < *j) return -1;
599   - else return 1;
  597 +
  598 + return (*i < *j) ? -1 : (*i > *j);
600 599 }
601 600
602 601 /*

1 comment on commit 94e7f64

Gerhard R.

For what it's worth, the C idiom for tri-state comparisons is

(*i > *j) - (*i < *j)

which is a well-known way to avoid integer overflow

Please sign in to comment.
Something went wrong with that request. Please try again.