-#define __MAKE_FLOAT(i) (((union { __uint32_t __i; float __f; }){ i }).__f)
-#define __FLOAT_BITS(f) (((union { float __f; __uint32_t __i; }){ f }).__i)
-#define __DOUBLE_BITS(f) (((union { double __f; __uint64_t __i; }){ f }).__i)
-
-#define NAN __MAKE_FLOAT(0x7fc00000)
-#define INFINITY __MAKE_FLOAT(0x7f800000)
+#if 100*__GNUC__+__GNUC_MINOR__ >= 303
+#define NAN __builtin_nanf("")
+#define INFINITY __builtin_inff()
+#else
+#define NAN (0.0f/0.0f)
+#define INFINITY 1e40f
+#endif