fix: optimize float display

This commit is contained in:
dapan1121 2024-11-01 09:13:04 +08:00
parent 016d176ea5
commit bda37462fc
1 changed files with 12 additions and 6 deletions

View File

@ -241,7 +241,10 @@ typedef struct {
case TSDB_DATA_TYPE_FLOAT: { \
int32_t n = snprintf(_output, (int32_t)(_outputBytes), "%f", *(float *)(_input)); \
if (n >= (_outputBytes)) { \
snprintf(_output, (int32_t)(_outputBytes), "%.7e", *(float *)(_input)); \
n = snprintf(_output, (int32_t)(_outputBytes), "%.7e", *(float *)(_input)); \
if (n >= (_outputBytes)) { \
snprintf(_output, (int32_t)(_outputBytes), "%f", *(float *)(_input)); \
} \
} \
break; \
} \
@ -249,6 +252,9 @@ typedef struct {
int32_t n = snprintf(_output, (int32_t)(_outputBytes), "%f", *(double *)(_input)); \
if (n >= (_outputBytes)) { \
snprintf(_output, (int32_t)(_outputBytes), "%.15e", *(double *)(_input)); \
if (n >= (_outputBytes)) { \
snprintf(_output, (int32_t)(_outputBytes), "%f", *(double *)(_input)); \
} \
} \
break; \
} \