zeroshade commented on code in PR #38426:
URL: https://github.com/apache/arrow/pull/38426#discussion_r1370485047


##########
go/arrow/decimal256/decimal256.go:
##########
@@ -506,7 +506,7 @@ func (n Num) FitsInPrecision(prec int32) bool {
 
 func (n Num) ToString(scale int32) string {
        f := (&big.Float{}).SetInt(n.BigInt())
-       f.Quo(f, (&big.Float{}).SetInt(scaleMultipliers[scale].BigInt()))
+       f.SetPrec(256).Quo(f, 
(&big.Float{}).SetInt(scaleMultipliers[scale].BigInt()))

Review Comment:
   In theory we are already ensuring that the value fits in a given precision 
(checks are made elsewhere), in addition the usage of the scale in the `Text` 
call ensures the correct number of digits in the text output. So setting the 
`SetPrec(256)` ensures we avoid rounding. Since this is Decimal256, we use 
precision 256 here (and 128 in the Decimal128 version)



-- 
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