scovich commented on code in PR #7785:
URL: https://github.com/apache/arrow-rs/pull/7785#discussion_r2167833083


##########
parquet-variant/src/variant/decimal.rs:
##########
@@ -15,6 +15,30 @@
 // specific language governing permissions and limitations
 // under the License.
 use arrow_schema::ArrowError;
+use std::fmt;
+
+// Macro to format decimal values, using only integer arithmetic to avoid 
floating point precision loss
+macro_rules! format_decimal {
+    ($f:expr, $integer:expr, $scale:expr, $int_type:ty) => {{
+        let integer = if $scale == 0 {
+            $integer
+        } else {
+            let divisor = (10 as $int_type).pow($scale as u32);

Review Comment:
   I was _sorely_ tempted to just define a helper function that takes i128, 
since it would also produce correct output for all narrower integer types. But 
128-bit division is _vastly_ more expensive than 32- or 64-bit division, and 
the narrower types usually produce quotient and remainder from a single machine 
instruction. 
   
   If we think that performance difference doesn't matter, then we should use 
the helper function instead for simplicity.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to