Matrix: correct print buffer size prediction

Apparently printf of %8.8g can result in
8 significant digits + dot + scientific notation e.g. "e+12" = 14 bytes
This commit is contained in:
Matthias Grob
2020-03-12 10:08:04 +01:00
committed by Julian Kent
parent 2cca35c8fe
commit c6db357c92
2 changed files with 13 additions and 7 deletions
+2 -2
View File
@@ -352,8 +352,8 @@ public:
void print(FILE *stream = stdout) const
{
// element: tab, point, 8 digits; row: newline; string: \0 end
static const size_t n = 10*N*M + M + 1;
// element: tab, point, 8 digits, 4 scientific notation chars; row: newline; string: \0 end
static const size_t n = 15*N*M + M + 1;
char * buf = new char[n];
write_string(buf, n);
fprintf(stream, "%s\n", buf);