From 9ab20893bad7eb87d78ba5500ba9e763dad954a0 Mon Sep 17 00:00:00 2001 From: Haoyang Li Date: Thu, 19 Oct 2023 15:58:05 +0800 Subject: [PATCH] Update src/main/cpp/src/cast_float_to_string.cu Co-authored-by: Mike Wilson --- src/main/cpp/src/cast_float_to_string.cu | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/cpp/src/cast_float_to_string.cu b/src/main/cpp/src/cast_float_to_string.cu index 15d6e9cba5..ca7e9b95db 100644 --- a/src/main/cpp/src/cast_float_to_string.cu +++ b/src/main/cpp/src/cast_float_to_string.cu @@ -172,11 +172,14 @@ struct ftos_converter { memcpy(output, "NaN", 3); return 3; } - bool bneg = false; - if (signbit(value)) { // handles -0.0 too - value = -value; - bneg = true; - } + bool const bneg = [&value]() { + if (signbit(value)) { // handles -0.0 too + value = -value; + return true; + } else { + return false; + } + }(); if (std::isinf(value)) { if (bneg) { memcpy(output, "-Infinity", 9);