I have strings which represents the decimal values,
ex: “0.010”, “0.0100000” “00.01000”
I want to round them to specified format,
ex: #.##
In Java we have:
public BigDecimal setScale(int newScale, RoundingMode roundingMode) {
return setScale(newScale, roundingMode.oldMode);
}
What is the best approach to achieve this in Clojure rather than using interop?
You can use Clojure’s
formatfor this purpose. It should provide you a solution to your problem. Here are some examples and a reference: