himadripal commented on code in PR #7179: URL: https://github.com/apache/arrow-rs/pull/7179#discussion_r2021959530
########## arrow-cast/src/parse.rs: ########## @@ -986,6 +1009,13 @@ pub fn parse_decimal<T: DecimalType>( "parse decimal overflow ({s})" ))); } + if scale == 0 { + result = result.div_wrapping(base.pow_wrapping(fractionals as u32)) + } + //add one if >=5 + if rounding_digit >= 5 { Review Comment: first we figure out what is the rounding_digit - digit which is next to the last digit in the final result (without rounding logic applied), if the value of the rounding_digit is >=5, then we add +1 to round up the result, else it remains same. ```rust "1265E-4" -> with scale 3 -> 0.127 in scale 3 the number would be 0.126 and rounding digit will be 5, as rounding digit >= 5, the result becomes 0.127 1264E-4" -> with scale 3 -> 0.126 here rounding_digit is 4, which is less than 5, so no need to add 1. ``` -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org