You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by vi...@apache.org on 2022/12/04 22:34:04 UTC

[arrow-rs] branch master updated: Fix decimal cast typo (#3270)

This is an automated email from the ASF dual-hosted git repository.

viirya pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git


The following commit(s) were added to refs/heads/master by this push:
     new 1640fd1bf Fix decimal cast typo (#3270)
1640fd1bf is described below

commit 1640fd1bf85bc6a51afc0b00ff037f37191da83d
Author: Raphael Taylor-Davies <17...@users.noreply.github.com>
AuthorDate: Sun Dec 4 22:33:58 2022 +0000

    Fix decimal cast typo (#3270)
---
 arrow-cast/src/cast.rs | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arrow-cast/src/cast.rs b/arrow-cast/src/cast.rs
index 372f0bd3c..6d43c996c 100644
--- a/arrow-cast/src/cast.rs
+++ b/arrow-cast/src/cast.rs
@@ -2044,14 +2044,14 @@ where
 
         let f = |x: I::Native| {
             // div is >= 10 and so this cannot overflow
-            let div = x.div_wrapping(div);
-            let rem = x.mod_wrapping(div);
+            let d = x.div_wrapping(div);
+            let r = x.mod_wrapping(div);
 
             // Round result
             let adjusted = match x >= I::Native::ZERO {
-                true if rem >= half => div.add_wrapping(I::Native::ONE),
-                false if rem <= half_neg => div.sub_wrapping(I::Native::ONE),
-                _ => div,
+                true if r >= half => d.add_wrapping(I::Native::ONE),
+                false if r <= half_neg => d.sub_wrapping(I::Native::ONE),
+                _ => d,
             };
             O::Native::from_decimal(adjusted)
         };