java - Get exponent of a BigDecimal -
i want exponent of bigdecimal.
`1m` (`1e0m`) -> `0` `10m` (`1e1m`) -> `1` `11m` (`1.1e1m`) -> `1` `1e2m` -> `2` `1.0e2m` -> `2` `100m` (`1.00e2m`) -> `2`
scale
, @ least itself, not need. rather not have use .toplainstring
, hack around that.
i'm little surprised exponent want isn't part of internal representation of bigdecimal.
i'm using bigdecimal clojure, logic works java welcome too.
(defn exp<-bigdec "returns exponent, b, bigdecimal in form * 10 ^ b." [x] (- (.precision x) (.scale x) 1))
Comments
Post a Comment