summaryrefslogtreecommitdiff
path: root/perl.h
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2014-09-12 07:24:15 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2014-09-12 07:54:41 -0400
commit99bf9e32fc57a4be2b3d9395384dc7bf2dc9d8e7 (patch)
tree01d4769459941557748195911c9d6155093854ab /perl.h
parent16334e6ed27593bc12382ef6095c56bc202a11d2 (diff)
downloadperl-99bf9e32fc57a4be2b3d9395384dc7bf2dc9d8e7.tar.gz
Use the multiplication test instead of the DBL_MAX/LDBL_MAX.
Comparing to decimal float constants feels unclean.
Diffstat (limited to 'perl.h')
-rw-r--r--perl.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/perl.h b/perl.h
index 39bf2410f4..55b33de886 100644
--- a/perl.h
+++ b/perl.h
@@ -2023,8 +2023,11 @@ EXTERN_C long double modfl(long double, long double *);
# define Perl_isfinite(x) isfinite(x)
# elif defined(HAS_FINITE)
# define Perl_isfinite(x) finite(x)
-# elif defined(DBL_MAX)
-# define Perl_isfinite(x) ((x) <= DBL_MAX && (x) >= -DBL_MAX)
+# else
+/* For the infinities the multiplication returns nan,
+ * for the nan the multiplication also returns nan,
+ * for everything else (that is, finite) zero should be returned. */
+# define Perl_isfinite(x) ((x) * 0 == 0)
# endif
# endif
#endif
@@ -2312,10 +2315,8 @@ int isnan(double d);
# define Perl_isfinitel(x) finitel(x)
# elif defined(HAS_INFL) && defined(HAS_NANL)
# define Perl_isfinitel(x) !(isinfl(x)||isnanl(x))
-# elif defined(LDBL_MAX)
-# define Perl_isfinitel(x) ((x) <= LDBL_MAX && (x) >= -LDBL_MAX)
# else
-# define Perl_isfinitel(x) ((x) * 0 == 0)
+# define Perl_isfinitel(x) ((x) * 0 == 0) /* See Perl_isfinite. */
# endif
#endif