Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
SiarheiFedartsou committed Sep 30, 2022
1 parent 87db480 commit 6bdbada
Showing 1 changed file with 26 additions and 25 deletions.
51 changes: 26 additions & 25 deletions include/util/json_renderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,31 +54,32 @@ template <typename Out> struct Renderer

void operator()(const Number &number)
{
char buffer[MAX_FLOAT_STRING_LENGTH] = {'\0'};
ieee754::dtoa_milo(number.value, buffer);

// Trucate to 10 decimal places
int pos = 0;
int decimalpos = 0;
while (decimalpos == 0 && pos < MAX_FLOAT_STRING_LENGTH && buffer[pos] != 0)
{
if (buffer[pos] == '.')
{
decimalpos = pos;
break;
}
++pos;
}
while (pos < MAX_FLOAT_STRING_LENGTH && buffer[pos] != 0)
{
if (pos - decimalpos == 10)
{
buffer[pos] = '\0';
break;
}
++pos;
}
write(buffer);
// char buffer[MAX_FLOAT_STRING_LENGTH] = {'\0'};
// ieee754::dtoa_milo(number.value, buffer);

// // Trucate to 10 decimal places
// int pos = 0;
// int decimalpos = 0;
// while (decimalpos == 0 && pos < MAX_FLOAT_STRING_LENGTH && buffer[pos] != 0)
// {
// if (buffer[pos] == '.')
// {
// decimalpos = pos;
// break;
// }
// ++pos;
// }
// while (pos < MAX_FLOAT_STRING_LENGTH && buffer[pos] != 0)
// {
// if (pos - decimalpos == 10)
// {
// buffer[pos] = '\0';
// break;
// }
// ++pos;
// }
const std::string number_string = cast::to_string_with_precision(number.value);
write(number_string);
}

void operator()(const Object &object)
Expand Down

0 comments on commit 6bdbada

Please sign in to comment.