G
G
gsaw2021-03-25 20:59:55
Java
gsaw, 2021-03-25 20:59:55

Why can BiDecimal.precision be zero?

Java 11

In the code I get a string, for example "1234", I convert it to BigDecimal("1234"). Then I call After that ret.precision () returns 0. unscaledValue returns 1234000. I need to check the input data, whether they fit into the database, whether they are cut off. I thought to check precision, but it is equal to 0. It turns out you need to check

ret = ret.setScale(3, RoundingMode.HALF_DOWN)




ret.unscaledValue().toString().length() <= заданные precision+scale ?


kind of weird

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question