Java – BigDecimal and BigInteger and BigDecimal performance
I'm discussing whether to use BigDecimal and BigInteger or just BigDecimal to make my life easier and less back and forth Is there a disadvantage in using BigDecimal only in terms of resources?
How can I use only raw data types and BigInteger or just BigInteger to make my life easier and less round-trip conversion?
Solution
come from: http://www.javamex.com/tutorials/math/BigDecimal_BigInteger_performance.shtml
Note that BigDecimal is essentially a wrapper around BigInteger, which "remembers the position of the decimal point"
Because we are used to dealing with numbers, as human beings, we may have to "think more" when using non integer calculations compared with integers (for example, we may have been used to some calculations in the 7th table, but it may not be. 7x table) However, for computer implementation, the operation of non integers is not more labor-saving than integers. Therefore, in general, the methods on BigDecimal are often similar to those on BigInteger