Converts decimal text to BigDecimal, keeping the precision written
All 4 scenarios hold
Cell text converts automatically to the declared parameter type. There is no type converter to write.
Every table below reads the same way. An Input value column holds the text as written in the cell. A Parameter type column holds the type the text converts to. Expectation columns state observable properties of the object the test method receives. Each row therefore shows that the text became a valid object of that type, and not merely that it converted.
The test method signature fixes a parameter type, and no row can vary it. Each type therefore gets its own short table.
A primitive type shares its table with its wrapper. The two are one type in two forms, and a boxed value does not report its primitive type. The value column's own header names it there, in place of a column of its own.
Scale is the number of digits after the decimal point. It is negative when scientific notation places the precision of the value above the point.
| Scenario | Input value | Parameter type? | BigDecimal as plain number? | BigDecimal scale? |
|---|---|---|---|---|
| Plain decimal | 3.14159 | java.math.BigDecimal | 3.14159 | 5 |
| Leading zero | 0.1 | java.math.BigDecimal | 0.1 | 1 |
| Scientific notation | 1.23e4 | java.math.BigDecimal | 12300 | -2 |
| No decimal point | 123 | java.math.BigDecimal | 123 | 0 |