Skip to content

Commit fa70bfe

Browse files
committed
fix: add NaN handling for math functions and update CMake to support C++17
1 parent b285fc4 commit fa70bfe

3 files changed

Lines changed: 7 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ project(simd-fp VERSION 1.1.1 LANGUAGES C CXX)
44
set(CMAKE_C_STANDARD 11)
55
set(CMAKE_C_STANDARD_REQUIRED ON)
66

7+
set(CMAKE_CXX_STANDARD 17)
8+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
9+
710
# -----------------------------------------------------------------------
811
# backend selection
912
# the library auto-detects the backend via preprocessor macros.

docs/demo/simd_f128_wasm.wasm

182 Bytes
Binary file not shown.

include/simd_f128_math.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ SIMD_F128_INLINE simd_f128 simd_f128_exp(simd_f128 x) {
6161
double hi, lo;
6262
simd_f128_extract(x, &hi, &lo);
6363

64+
if (isnan(hi)) return simd_f128_from_double(NAN);
65+
6466
// catch overflow/underflow early
6567
if (hi > 709.0) return simd_f128_from_double(INFINITY);
6668
if (hi < -745.0) return simd_f128_from_double(0.0);
@@ -231,6 +233,8 @@ SIMD_F128_INLINE simd_f128 simd_f128_atan2(simd_f128 y, simd_f128 x) {
231233
simd_f128_extract(y, &yhi, &ylo);
232234
simd_f128_extract(x, &xhi, &xlo);
233235

236+
if (isnan(xhi) || isnan(yhi)) return simd_f128_from_double(NAN);
237+
234238
if (xhi == 0.0 && yhi == 0.0) return simd_f128_from_double(0.0);
235239

236240
if (xhi > 0.0) {

0 commit comments

Comments
 (0)