Skip to content

Commit

Permalink
Add comments for changes
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonylouisbsb committed Apr 13, 2021
1 parent cec11bb commit b62b856
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
9 changes: 9 additions & 0 deletions cpp/src/arrow/vendored/double-conversion/double-conversion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ void DoubleToStringConverter::CreateExponentialRepresentation(
ASSERT(length != 0);
result_builder->AddCharacter(decimal_digits[0]);

/* If the mantissa of the scientific notation representation is an integer number,
* the EMIT_TRAILING_DECIMAL_POINT flag will add a '.' character at the end of the
* representation:
* - With EMIT_TRAILING_DECIMAL_POINT enabled -> 0.0009 => 9.E-4
* - With EMIT_TRAILING_DECIMAL_POINT disabled -> 0.0009 => 9E-4
*
* If the mantissa is an integer and the EMIT_TRAILING_ZERO_AFTER_POINT flag is enabled
* it will add a '0' character at the end of the mantissa representation. Note that that
* flag depends on EMIT_TRAILING_DECIMAL_POINT flag be enabled.*/
if(length == 1){
if ((flags_ & EMIT_TRAILING_DECIMAL_POINT) != 0) {
result_builder->AddCharacter('.');
Expand Down
11 changes: 11 additions & 0 deletions cpp/src/arrow/vendored/double-conversion/double-conversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,17 @@ class DoubleToStringConverter {
// ToPrecision(230.0, 2) -> "230"
// ToPrecision(230.0, 2) -> "230." with EMIT_TRAILING_DECIMAL_POINT.
// ToPrecision(230.0, 2) -> "2.3e2" with EMIT_TRAILING_ZERO_AFTER_POINT.
//
// When converting numbers to scientific notation representation, if the mantissa of
// the representation is an integer number, the EMIT_TRAILING_DECIMAL_POINT flag will
// add a '.' character at the end of the representation:
// - With EMIT_TRAILING_DECIMAL_POINT enabled -> 0.0009 => 9.E-4
// - With EMIT_TRAILING_DECIMAL_POINT disabled -> 0.0009 => 9E-4
//
// If the mantissa is an integer and the EMIT_TRAILING_ZERO_AFTER_POINT flag is enabled
// it will add a '0' character at the end of the mantissa representation. Note that that
// flag depends on EMIT_TRAILING_DECIMAL_POINT flag be enabled.
// - With EMIT_TRAILING_ZERO_AFTER_POINT enabled -> 0.0009 => 9.0E-4
DoubleToStringConverter(int flags,
const char* infinity_symbol,
const char* nan_symbol,
Expand Down
12 changes: 11 additions & 1 deletion cpp/src/gandiva/formatting_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,21 @@ class FloatToStringGdvMixin
using arrow::internal::FloatToStringFormatterMixin<
ARROW_TYPE>::FloatToStringFormatterMixin;

// The mixin is a modified version of the existent FloatToStringFormatterMixin, but
// it defines some specific parameters in the FloatToStringFormatterMixin to cast
// the float numbers to string using the same patterns like Java.
//
// The Java real numbers are represented in two ways following these rules:
//- If the number is greater or equals than 10^7 and less than 10^(-3)
// it will be represented using scientific notation, e.g:
// - 0.000012 -> 1.2E-5
// - 10000002.3 -> 1.00000023E7
//- If the numbers are between that interval above, they are showed as is.
explicit FloatToStringGdvMixin(const std::shared_ptr<arrow::DataType>& = NULLPTR)
: arrow::internal::FloatToStringFormatterMixin<ARROW_TYPE>(
DoubleToStringConverter::EMIT_TRAILING_ZERO_AFTER_POINT |
DoubleToStringConverter::EMIT_TRAILING_DECIMAL_POINT,
"inf", "nan", 'E', -3, 7, 3, 1) {}
"Infinity", "NaN", 'E', -3, 7, 3, 1) {}
};

template <>
Expand Down

0 comments on commit b62b856

Please sign in to comment.