This article is a mirror article of machine translation, please click here to jump to the original article.

View: 1024|Reply: 0

[Source] toPlainString, toEngineeringString, toString for BigDecimal in Java

[Copy link]
Posted on 3/26/2025 2:21:51 PM | | | |
When printing with java.math.BigDecimal, we are often curious about the conversion strings provided by BigDecimal.

  • stripTrailingZeros(): Removes all zeros at the decimal tail and returns a BigDecimal type of data, which is not guaranteed to be scientific notation
  • toPlainString(): No exponents used (never scientific notation)
  • toString(): Use scientific notation when necessary
  • toEngineeringString(): Use engineering counters when necessary. Engineering notation is a method of recording numbers often used in engineering calculations, similar to scientific notation, but requires that the power of 10 must be a multiple of 3

No exponents are used
Scientific notation method
Engineering notation method
0.0001
0.0001
0.0001
0.0000001
1E-7
100E-9

Code:



(End)




Previous:[AI] (15) The vector database Qdrant is easy to use
Next:[AI] (16) Semantic Kernel is based on Qwen to test Function Calling
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com