简体   繁体   中英

Long vs. BigInteger

As I understand, I can abstract the precision away using the Number interface, which has Integer, Long and BigInteger implementations and plug the type I need depending on the range of my values. I understand the BigInteger is not ubiquitous because it takes more memory and less performant. What are the figures?

BigDecimal is similar to double , it can help maintain precision and is useful for display purposes. Use it only when needed, otherwise double is better for many considerations (memory, performance).

It's useful for instance when storing money values: you want to keep the representation, as well as round the number right when doing sums (additions).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM