How do I write a test to verify that BigDecimal.toPlainString()
returns numeric value, but not exponential?
For example
BigDecimal.valueOf("0.00000006").toPlainString()
I want to write a test without comparing the result of the toPlainString()
method and without having an expected value, so I will not be locked into an exact BigDecimal value. Let’s say I need a boolean isNotExponencial(String value)
method
5
I don’t understand 100% what you mean, but I guess you need a function that gets a string argument that represents a BigDecimal so you can use this
public static boolean isNotExponential(String value) {
// Check if the value contains 'e' or 'E' indicating exponential notation
return !value.toLowerCase().contains("e");
}
2