瀏覽代碼

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 13 年之前
父節點
當前提交
7680eca5d8
共有 1 個文件被更改,包括 10 次插入3 次删除
  1. +10
    -3
      test/half.cpp

+ 10
- 3
test/half.cpp 查看文件

@@ -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


Loading…
取消
儲存