Report error when loading decimal value with scientific notation (#428)
Currently we do not support scientific notation of decimal value.
This commit is contained in:
@ -900,26 +900,27 @@ int DecimalValue::parse_from_str(const char* decimal_str, int32_t length) {
|
||||
*buff = value * powers10[DIG_PER_DEC1 - index_in_powers10];
|
||||
}
|
||||
|
||||
// Handle exponent
|
||||
// TODO: we do not support decimal in scientific notation
|
||||
if ((frac_ptr + 1) < end && (*frac_ptr == 'e' || *frac_ptr == 'E')) {
|
||||
int64_t exponent = strtoll(frac_ptr + 1, (char**) end, 10);
|
||||
if (end != frac_ptr + 1) { // If at least one digit
|
||||
if (errno) { // system error number, it is thread local
|
||||
set_to_zero();
|
||||
return E_DEC_BAD_NUM;
|
||||
}
|
||||
if (exponent > (INT_MAX / 2) || (errno == 0 && exponent < 0)) {
|
||||
set_to_zero();
|
||||
return E_DEC_OVERFLOW;
|
||||
}
|
||||
if (exponent < INT_MAX / 2 && error != E_DEC_OVERFLOW) {
|
||||
set_to_zero();
|
||||
return E_DEC_TRUNCATED;
|
||||
}
|
||||
if (error != E_DEC_OVERFLOW) {
|
||||
// error = shift((int32_t) exponent);
|
||||
}
|
||||
}
|
||||
return E_DEC_BAD_NUM;
|
||||
// int64_t exponent = strtoll(frac_ptr + 1, (char**) &end, 10);
|
||||
// if (end != frac_ptr + 1) { // If at least one digit
|
||||
// if (errno) { // system error number, it is thread local
|
||||
// set_to_zero();
|
||||
// return E_DEC_BAD_NUM;
|
||||
// }
|
||||
// if (exponent > (INT_MAX / 2) || (errno == 0 && exponent < 0)) {
|
||||
// set_to_zero();
|
||||
// return E_DEC_OVERFLOW;
|
||||
// }
|
||||
// if (exponent < INT_MAX / 2 && error != E_DEC_OVERFLOW) {
|
||||
// set_to_zero();
|
||||
// return E_DEC_TRUNCATED;
|
||||
// }
|
||||
// if (error != E_DEC_OVERFLOW) {
|
||||
// // error = shift((int32_t) exponent);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
if (_sign && is_zero()) {
|
||||
_sign = false;
|
||||
|
||||
Reference in New Issue
Block a user