From d91b160a95781028f69fe3f567453d3096606d1c Mon Sep 17 00:00:00 2001 From: Gleb Belov Date: Mon, 8 Jan 2024 14:11:08 +1100 Subject: [PATCH] NLWriter: print -0 as 0 #30 Discard usage of macro IEEE_8087 not set in MP --- CMakeLists.txt | 2 +- nl-writer2/CMakeLists.txt | 10 ++++++++-- nl-writer2/src/nl-writer2.cc | 10 +--------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ed40e1bb3..c632b7184 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -492,7 +492,7 @@ endif () # Build NLWriter2 example if (BUILD_EXAMPLES) message(STATUS - "Building NLWriter2 example. Set -DBUILD_EXAMPLES=off to switch off.") + "Building NLWriter2 examples. Set -DBUILD_EXAMPLES=off to switch off.") set(NLW2_DIR nl-writer2) add_subdirectory(${NLW2_DIR}) # Gather source files for docu diff --git a/nl-writer2/CMakeLists.txt b/nl-writer2/CMakeLists.txt index 4dfb45e62..dbda8fd3a 100644 --- a/nl-writer2/CMakeLists.txt +++ b/nl-writer2/CMakeLists.txt @@ -102,13 +102,19 @@ if (BUILD_EXAMPLES_NLW2) # Actually build the example target_include_directories(nl-writer-example-cpp PUBLIC ${NLW2_INCLUDE_PATH}) target_link_libraries(nl-writer-example-cpp ${NLW2_LIB_NAME}) - add_dependencies(nl-writer-example-cpp mp) + ## if actually building mp. Otherwise make sure nl-opcodes.h has been generated + if (TARGET mp) + add_dependencies(nl-writer-example-cpp mp) + endif() add_executable(nl-writer-example-c ${NLSOL_C_EX_FILES}) target_include_directories(nl-writer-example-c PUBLIC ${NLW2_INCLUDE_PATH}) target_link_libraries(nl-writer-example-c ${NLW2_C_API_LIB_NAME}) - add_dependencies(nl-writer-example-c mp) + ## if actually building mp. Otherwise make sure nl-opcodes.h has been generated + if (TARGET mp) + add_dependencies(nl-writer-example-c mp) + endif() endif() diff --git a/nl-writer2/src/nl-writer2.cc b/nl-writer2/src/nl-writer2.cc index 4e4839288..c70505c16 100644 --- a/nl-writer2/src/nl-writer2.cc +++ b/nl-writer2/src/nl-writer2.cc @@ -327,15 +327,7 @@ g_fmt(char *b, double x, int prec) char *b0, sbuf[400], *se; b0 = b; -#if defined(_WIN32) || defined(_WIN64) -#ifdef IEEE_8087 - if (!(((Long*)&x)[1] & 0x7fffffff | ((Long*)&x)[0])) { -#else - if (!(((Long*)&x)[0] & 0x7fffffff | ((Long*)&x)[1])) { -#endif /* IEEE_8087 */ -#else /* _WIN32 || _WIN64 */ - if (! x) { -#endif /*_WIN32 || _WIN64 */ + if (! x) { // Report -0 as '0' *b++ = '0'; *b = 0; goto done;