diff mbox series

[v1,05/14] softfloat: add float32_is_normal and float64_is_normal

Message ID 1521663109-32262-6-git-send-email-cota@braap.org
State New
Headers show
Series fp-test + hostfloat | expand

Commit Message

Emilio Cota March 21, 2018, 8:11 p.m. UTC
This paves the way for upcoming work.

Signed-off-by: Emilio G. Cota <cota@braap.org>
---
 include/fpu/softfloat.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Alex Bennée March 27, 2018, 11:34 a.m. UTC | #1
Emilio G. Cota <cota@braap.org> writes:

> This paves the way for upcoming work.
>
> Signed-off-by: Emilio G. Cota <cota@braap.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

> ---
>  include/fpu/softfloat.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
> index 36626a5..7b9d31c 100644
> --- a/include/fpu/softfloat.h
> +++ b/include/fpu/softfloat.h
> @@ -402,6 +402,11 @@ static inline int float32_is_zero(float32 a)
>      return (float32_val(a) & 0x7fffffff) == 0;
>  }
>
> +static inline bool float32_is_normal(float32 a)
> +{
> +    return ((float32_val(a) + 0x00800000) & 0x7fffffff) >= 0x01000000;
> +}
> +
>  static inline int float32_is_any_nan(float32 a)
>  {
>      return ((float32_val(a) & ~(1 << 31)) > 0x7f800000UL);
> @@ -531,6 +536,11 @@ static inline int float64_is_zero(float64 a)
>      return (float64_val(a) & 0x7fffffffffffffffLL) == 0;
>  }
>
> +static inline bool float64_is_normal(float64 a)
> +{
> +    return ((float64_val(a) + (1ULL << 52)) & -1ULL >> 1) >= 1ULL << 53;
> +}
> +
>  static inline int float64_is_any_nan(float64 a)
>  {
>      return ((float64_val(a) & ~(1ULL << 63)) > 0x7ff0000000000000ULL);


--
Alex Bennée
diff mbox series

Patch

diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h
index 36626a5..7b9d31c 100644
--- a/include/fpu/softfloat.h
+++ b/include/fpu/softfloat.h
@@ -402,6 +402,11 @@  static inline int float32_is_zero(float32 a)
     return (float32_val(a) & 0x7fffffff) == 0;
 }
 
+static inline bool float32_is_normal(float32 a)
+{
+    return ((float32_val(a) + 0x00800000) & 0x7fffffff) >= 0x01000000;
+}
+
 static inline int float32_is_any_nan(float32 a)
 {
     return ((float32_val(a) & ~(1 << 31)) > 0x7f800000UL);
@@ -531,6 +536,11 @@  static inline int float64_is_zero(float64 a)
     return (float64_val(a) & 0x7fffffffffffffffLL) == 0;
 }
 
+static inline bool float64_is_normal(float64 a)
+{
+    return ((float64_val(a) + (1ULL << 52)) & -1ULL >> 1) >= 1ULL << 53;
+}
+
 static inline int float64_is_any_nan(float64 a)
 {
     return ((float64_val(a) & ~(1ULL << 63)) > 0x7ff0000000000000ULL);