| 285 | |
| 286 | template <typename Decimal> |
| 287 | typename DecimalConverter<Decimal>::GArrowType * |
| 288 | garrow_decimal_divide(typename DecimalConverter<Decimal>::GArrowType *left, |
| 289 | typename DecimalConverter<Decimal>::GArrowType *right, |
| 290 | typename DecimalConverter<Decimal>::GArrowType **remainder, |
| 291 | GError **error, |
| 292 | const gchar *tag) |
| 293 | { |
| 294 | DecimalConverter<Decimal> converter; |
| 295 | auto arrow_left = converter.get_raw(left); |
| 296 | auto arrow_right = converter.get_raw(right); |
| 297 | auto arrow_result = arrow_left->Divide(*arrow_right); |
| 298 | if (garrow::check(error, arrow_result, tag)) { |
| 299 | Decimal arrow_quotient_raw; |
| 300 | Decimal arrow_remainder_raw; |
| 301 | std::tie(arrow_quotient_raw, arrow_remainder_raw) = *arrow_result; |
| 302 | if (remainder) { |
| 303 | auto arrow_remainder = std::make_shared<Decimal>(arrow_remainder_raw); |
| 304 | *remainder = converter.new_raw(&arrow_remainder); |
| 305 | } |
| 306 | auto arrow_quotient = std::make_shared<Decimal>(arrow_quotient_raw); |
| 307 | return converter.new_raw(&arrow_quotient); |
| 308 | } else { |
| 309 | if (remainder) { |
| 310 | *remainder = NULL; |
| 311 | } |
| 312 | return NULL; |
| 313 | } |
| 314 | } |
| 315 | |
| 316 | template <typename Decimal> |
| 317 | typename DecimalConverter<Decimal>::GArrowType * |