Skip to content

Commit

Permalink
Fixed float number truncation in cjson library reading configuration …
Browse files Browse the repository at this point in the history
…item min
  • Loading branch information
YamingPei committed Jul 3, 2024
1 parent e728b26 commit 7477af7
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions src/benchJsonOpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,25 +260,25 @@ static int getColumnAndTagTypeFromInsertJsonFile(
}

double valueRange = maxInDbl - minInDbl;
tools_cJSON *dataScalingFactor = tools_cJSON_GetObjectItem(column, "scalingFactor");
if (tools_cJSON_IsNumber(dataScalingFactor)) {
scalingFactor = dataScalingFactor->valueint;
if (scalingFactor > 1) {
max = maxInDbl * scalingFactor;
min = minInDbl * scalingFactor;
} else {
scalingFactor = 1;
}
} else {
if (0 < valueRange && valueRange <= 1) {
scalingFactor = 1000;
max = maxInDbl * scalingFactor;
min = minInDbl * scalingFactor;
} else {
scalingFactor = 1;
}
}

tools_cJSON *dataScalingFactor = tools_cJSON_GetObjectItem(column, "scalingFactor");
if (tools_cJSON_IsNumber(dataScalingFactor)) {
scalingFactor = dataScalingFactor->valueint;
if (scalingFactor > 1) {
max = maxInDbl * scalingFactor;
min = minInDbl * scalingFactor;
} else {
scalingFactor = 1;
}
} else {
if (0 < valueRange && valueRange <= 1) {
scalingFactor = 1000;
max = maxInDbl * scalingFactor;
min = minInDbl * scalingFactor;
} else {
scalingFactor = 1;
}
}

// gen
tools_cJSON *dataGen = tools_cJSON_GetObjectItem(column, "gen");
if (tools_cJSON_IsString(dataGen)) {
Expand Down

0 comments on commit 7477af7

Please sign in to comment.