shithub: npe

Download patch

ref: bd64760ce92e4da423a9330021e8f09b0de5fc73
parent: ba18316f3785076989db44a6ac2eb96ef623cf09
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Sun Jun 20 07:36:21 EDT 2021

math: add INFINITY and NAN

--- a/include/npe/math.h
+++ b/include/npe/math.h
@@ -5,6 +5,12 @@
 
 #define M_PI 3.14159265358979323846
 
+float npe_infinity(void);
+#define INFINITY (npe_infinity())
+
+float npe_nan(void);
+#define NAN (npe_nan())
+
 #define isnan isNaN
 
 #define acosf acos
--- a/libnpe/_npe.c
+++ b/libnpe/_npe.c
@@ -86,3 +86,23 @@
 
 	return 0;
 }
+
+float
+npe_infinity(void)
+{
+	union {float f; u32int i;} u;
+
+	u.i = 0x7f800000;
+
+	return u.f;
+}
+
+float
+npe_nan(void)
+{
+	union {float f; u32int i;} u;
+
+	u.i = 0x7fbfffff;
+
+	return u.f;
+}