Hi there,
Right now, it doesn't seem like the valueOf() methods on the decimal4j classes are able to parse strings that are the scientific notation representation of numbers. For example, if I want to create a Decimal4f instance of the string representation of the number 0.0003, I'll try something like this:
double myNumber = 0.0003;
String myNumberString = String.valueOf(myNumber);
System.out.println(myNumberString); // prints "3.0E-4"
Decimal4f myNumberDecimal = new Decimal4f.valueOf(myNumberString)
I'll get a NumberFormatException error on that last line with the message of Cannot parse Decimal value with scale 4 for input string: "3.0E-4".
It'd be great to have the library accommodate scientific notation strings -- this is something BigDecimal does, so if we want to use decimal4j classes to parse strings, we have to first feed the string into a BigDecimal and then feed that into the decimal4j class.
Thanks!
Hi there,
Right now, it doesn't seem like the
valueOf()methods on thedecimal4jclasses are able to parse strings that are the scientific notation representation of numbers. For example, if I want to create aDecimal4finstance of the string representation of the number0.0003, I'll try something like this:I'll get a
NumberFormatExceptionerror on that last line with the message ofCannot parse Decimal value with scale 4 for input string: "3.0E-4".It'd be great to have the library accommodate scientific notation strings -- this is something
BigDecimaldoes, so if we want to usedecimal4jclasses to parse strings, we have to first feed the string into aBigDecimaland then feed that into thedecimal4jclass.Thanks!