From 3e6ffec5297f2a924894dad9b000ee75f97fb508 Mon Sep 17 00:00:00 2001 From: Shungang Li Date: Tue, 14 Nov 2023 11:47:42 +0800 Subject: [PATCH] fix: support float value with unit --- source/util/src/tunit.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/util/src/tunit.c b/source/util/src/tunit.c index b0630ec8ca..d3447294ea 100644 --- a/source/util/src/tunit.c +++ b/source/util/src/tunit.c @@ -35,27 +35,27 @@ int64_t taosStrHumanToInt64(const char* str) { strNoUnit = taosMemoryCalloc(sLen, 1); memcpy(strNoUnit, str, sLen - 1); - val = atoll(strNoUnit) * UNIT_ONE_PEBIBYTE; + val = atof(strNoUnit) * UNIT_ONE_PEBIBYTE; } else if ((unit == 'T') || (unit == 't')) { strNoUnit = taosMemoryCalloc(sLen, 1); memcpy(strNoUnit, str, sLen - 1); - val = atoll(strNoUnit) * UNIT_ONE_TEBIBYTE; + val = atof(strNoUnit) * UNIT_ONE_TEBIBYTE; } else if ((unit == 'G') || (unit == 'g')) { strNoUnit = taosMemoryCalloc(sLen, 1); memcpy(strNoUnit, str, sLen - 1); - val = atoll(strNoUnit) * UNIT_ONE_GIBIBYTE; + val = atof(strNoUnit) * UNIT_ONE_GIBIBYTE; } else if ((unit == 'M') || (unit == 'm')) { strNoUnit = taosMemoryCalloc(sLen, 1); memcpy(strNoUnit, str, sLen - 1); - val = atoll(strNoUnit) * UNIT_ONE_MEBIBYTE; + val = atof(strNoUnit) * UNIT_ONE_MEBIBYTE; } else if ((unit == 'K') || (unit == 'k')) { strNoUnit = taosMemoryCalloc(sLen, 1); memcpy(strNoUnit, str, sLen - 1); - val = atoll(strNoUnit) * UNIT_ONE_KIBIBYTE; + val = atof(strNoUnit) * UNIT_ONE_KIBIBYTE; } else { val = atoll(str); } @@ -93,17 +93,17 @@ int32_t taosStrHumanToInt32(const char* str) { strNoUnit = taosMemoryCalloc(sLen, 1); memcpy(strNoUnit, str, sLen - 1); - val = atoll(strNoUnit) * UNIT_ONE_GIBIBYTE; + val = atof(strNoUnit) * UNIT_ONE_GIBIBYTE; } else if ((unit == 'M') || (unit == 'm')) { strNoUnit = taosMemoryCalloc(sLen, 1); memcpy(strNoUnit, str, sLen - 1); - val = atoll(strNoUnit) * UNIT_ONE_MEBIBYTE; + val = atof(strNoUnit) * UNIT_ONE_MEBIBYTE; } else if ((unit == 'K') || (unit == 'k')) { strNoUnit = taosMemoryCalloc(sLen, 1); memcpy(strNoUnit, str, sLen - 1); - val = atoll(strNoUnit) * UNIT_ONE_KIBIBYTE; + val = atof(strNoUnit) * UNIT_ONE_KIBIBYTE; } else { val = atoll(str); }