public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-2229] Add real_iszero to real.*
@ 2022-08-26 18:45 Aldy Hernandez
  0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2022-08-26 18:45 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:1d3145360f95910f0661da0364b91dc7962d44fa

commit r13-2229-g1d3145360f95910f0661da0364b91dc7962d44fa
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Fri Aug 26 16:57:09 2022 +0200

    Add real_iszero to real.*
    
    We have real_isnegzero but no real_iszero.  We could memcmp with 0,
    but that's just ugly.
    
    gcc/ChangeLog:
    
            * real.cc (real_iszero): New.
            * real.h (real_iszero): New.

Diff:
---
 gcc/real.cc | 16 ++++++++++++++++
 gcc/real.h  |  6 ++++++
 2 files changed, 22 insertions(+)

diff --git a/gcc/real.cc b/gcc/real.cc
index dcf41b79f60..96f05ec68ca 100644
--- a/gcc/real.cc
+++ b/gcc/real.cc
@@ -1272,6 +1272,22 @@ real_isneg (const REAL_VALUE_TYPE *r)
   return r->sign;
 }
 
+/* Determine whether a floating-point value X is plus or minus zero.  */
+
+bool
+real_iszero (const REAL_VALUE_TYPE *r)
+{
+  return r->cl == rvc_zero;
+}
+
+/* Determine whether a floating-point value X is zero with SIGN.  */
+
+bool
+real_iszero (const REAL_VALUE_TYPE *r, bool sign)
+{
+  return real_iszero (r) && r->sign == sign;
+}
+
 /* Determine whether a floating-point value X is minus zero.  */
 
 bool
diff --git a/gcc/real.h b/gcc/real.h
index e01f9ed7282..ec78e8a8932 100644
--- a/gcc/real.h
+++ b/gcc/real.h
@@ -295,6 +295,12 @@ extern bool real_isneg (const REAL_VALUE_TYPE *);
 /* Determine whether a floating-point value X is minus zero.  */
 extern bool real_isnegzero (const REAL_VALUE_TYPE *);
 
+/* Determine whether a floating-point value X is plus or minus zero.  */
+extern bool real_iszero (const REAL_VALUE_TYPE *);
+
+/* Determine whether a floating-point value X is zero with SIGN.  */
+extern bool real_iszero (const REAL_VALUE_TYPE *, bool sign);
+
 /* Test relationships between reals.  */
 extern bool real_identical (const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *);
 extern bool real_equal (const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-26 18:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-26 18:45 [gcc r13-2229] Add real_iszero to real.* Aldy Hernandez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).