Github user viirya commented on the pull request:

    https://github.com/apache/spark/pull/7056#issuecomment-118081736
  
    @JihongMA Thanks for reporting this.
    As I tested, this behavior is the same as for Java's BigDecimal. So I am 
wondering if this is really a problem to fix? Because when you create 
`Decimal(2)` or `java.math.BigDecimal(2)`, actually you mean to create it with 
precision 1 and scale 0, right? So isn't that the result can be expected?
    
        scala> val t = new java.math.BigDecimal(2)
        t: java.math.BigDecimal = 2
        scala> val s = new java.math.BigDecimal(3)
        s: java.math.BigDecimal = 3
        scala> t.divide(s)
        java.lang.ArithmeticException: Non-terminating decimal expansion; no 
exact representable decimal result.
          at java.math.BigDecimal.divide(BigDecimal.java:1616)
          ... 33 elided
        scala> t.divide(s, BigDecimal.RoundingMode.HALF_UP.id)
        res24: java.math.BigDecimal = 1
    



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to