1
0
mirror of https://github.com/mariadb-corporation/mariadb-columnstore-engine.git synced 2025-07-30 19:23:07 +03:00

MCOL-299 Change the getStrVal() for float and double to match the results of the mariadb display string for same.

This commit is contained in:
David Hall
2016-09-22 09:34:13 -05:00
parent e48ef0063a
commit afab801b5f
3 changed files with 555 additions and 471 deletions

View File

@ -39,8 +39,7 @@
#include "calpontsystemcatalog.h"
#include "exceptclasses.h"
#include "dataconvert.h"
namespace messageqcpp {
namespace messageqecpp {
class ByteStream;
}
@ -483,8 +482,24 @@ inline const std::string& TreeNode::getStrVal()
}
else
{
snprintf(tmp, 312, "%e", fResult.floatVal);
fResult.strVal = tmp;
// MCOL-299 Print scientific with 5 mantissa and no + sign for exponent
int exponent = (int)floor(log10( fabs(fResult.floatVal))); // This will round down the exponent
double base = fResult.floatVal * pow(10, -1.0*exponent);
if (isnan(exponent) || isnan(base))
{
snprintf(tmp, 312, "%f", fResult.floatVal);
fResult.strVal = removeTrailing0(tmp, 312);
}
else
{
snprintf(tmp, 312, "%.5f", base);
fResult.strVal = removeTrailing0(tmp, 312);
snprintf(tmp, 312, "e%02d", exponent);
fResult.strVal += tmp;
}
// snprintf(tmp, 312, "%e.5", fResult.floatVal);
// fResult.strVal = tmp;
}
break;
}
@ -499,8 +514,23 @@ inline const std::string& TreeNode::getStrVal()
}
else
{
snprintf(tmp, 312, "%e", fResult.doubleVal);
fResult.strVal = tmp;
// MCOL-299 Print scientific with 9 mantissa and no + sign for exponent
int exponent = (int)floor(log10( fabs(fResult.doubleVal))); // This will round down the exponent
double base = fResult.doubleVal * pow(10, -1.0*exponent);
if (isnan(exponent) || isnan(base))
{
snprintf(tmp, 312, "%f", fResult.doubleVal);
fResult.strVal = removeTrailing0(tmp, 312);
}
else
{
snprintf(tmp, 312, "%.9f", base);
fResult.strVal = removeTrailing0(tmp, 312);
snprintf(tmp, 312, "e%02d", exponent);
fResult.strVal += tmp;
}
// snprintf(tmp, 312, "%e", fResult.doubleVal);
// fResult.strVal = tmp;
}
break;
}