From 24075e25dc6a43bfef3f43682010f842c775d4ee Mon Sep 17 00:00:00 2001 From: Aidan Crilly <20111148+aidancrilly@users.noreply.github.com> Date: Thu, 18 Apr 2024 15:07:56 +0100 Subject: [PATCH] Fix issue with C++ endf float converter (#7) Co-authored-by: aidancrilly --- src/endf/_records.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/endf/_records.cpp b/src/endf/_records.cpp index 8090bfa..e8165ac 100644 --- a/src/endf/_records.cpp +++ b/src/endf/_records.cpp @@ -16,7 +16,7 @@ double cfloat_endf(const char* buffer) { - char arr[12]; // 11 characters plus a null terminator + char arr[13]; // 11 characters plus e and a null terminator int j = 0; // current position in arr int found_significand = 0; int found_exponent = 0; @@ -25,6 +25,7 @@ double cfloat_endf(const char* buffer) int n = std::strlen(buffer); int i; + for (i = 0; i < n; ++i) { char c = buffer[i]; @@ -51,6 +52,7 @@ double cfloat_endf(const char* buffer) // Copy character arr[j++] = c; + } // Done copying. Add null terminator and convert to double