Pārlūkot izejas kodu

test: implement a custom isnan()

This version is faster (about 25% on x86_64) and works when extreme
optimisation options such as -ffast-math are used.
legacy
Sam Hocevar sam pirms 13 gadiem
vecāks
revīzija
7680eca5d8
1 mainītis faili ar 10 papildinājumiem un 3 dzēšanām
  1. +10
    -3
      test/half.cpp

+ 10
- 3
test/half.cpp Parādīt failu

@@ -21,10 +21,17 @@

#include "core.h"

/* This will not work with aggressive optimisation, but a reasonable
* assumption is that such environments do have a proper isnan(). */
/* Ensure isnan() is present even on systems that don't define it, or
* when -ffast-math is being used. */
#if defined __FAST_MATH__
# undef isnan
#endif
#if !defined isnan
# define isnan(x) (!((x) == (x)))
static inline int isnan(float f)
{
union { float f; uint32_t x; } u = { f };
return (~u.x << 1) < 0x00fffffeu;
}
#endif

namespace lol


Notiek ielāde…
Atcelt
Saglabāt